Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8771593
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T17:49:44+00:00 2026-06-13T17:49:44+00:00

I need to figure out how to get an element on an enum in

  • 0

I need to figure out how to get an element on an enum in an array.
Basically, I have a grid of 9×9 buttons. I have two multi-dimensional arrays that houses these values. One houses their names (if the name is 43) it means 5 down, 4 across (because they start at 0). The name is also the same as the ELEMENT of itself in the array.

string[,] playingField = new string[9, 9];
enum CellType { Empty, Flag, Hidden, Bomb }
CellType[,] cells = new CellType[9, 9];

the names of the buttons are held in playingField.
the status of each cell is held in cells (if it is empty, has a bomb, etc.)

Credit to AbdElRaheim for giving the above. The reason I’m doing this is so I can get a button name (exactly the same as the element name) which will be the same in both arrays.
For example: I can do this:

string dim1 = Convert.ToString(btn.Name[0]);
string dim2 = Convert.ToString(btn.Name[1]);
if (cells[Convert.ToInt32(dim1), Convert.ToInt32(dim2)] == CellType.Bomb)

(please excuse my terrible converting. i’ll fix that up later ;)) and what the above does is it allows me to see if a cell that you click has a bomb under it.

However, what I need to do now, is essentially reverse of this. In the above I know the element name that I want to compare it to, because the element name is the same as the button name. However, now what I need to do is FIND the element name (button name) by getting the element of all elements that are Bomb in cells.

I’m not sure how to do this, I tried:

foreach (CellType Bomb in cells)
{

but it doesn’t do anything. I need to find all ‘bomb’ in ‘cells’ and return the element name. That way I can use that element name, convert it to string, and use my StringToButton method to create a reference to the button.

This is the way I’m currently doing it, for reference, and to help you understand a little better, but take note this is NOT the way I want to continue doing it. I want to do it the way I asked about above 🙂

foreach (string i in minedNodes)
{
    Button buttonName = StringToButton(Convert.ToString(i));
    buttonName.Image = new Bitmap(dir + "mine.png");
}

Thanks!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T17:49:45+00:00Added an answer on June 13, 2026 at 5:49 pm

    If you are looking for a way to traverse your cells array, you would do this:

    int oi, ii;
    for (oi = 0; oi <= cells.GetUpperBound(0); ++oi)
    {
        for (ii = 0; ii <= cells.GetUpperBound(1); ++ii)
        {
            System.Diagnostics.Debug.WriteLine(
                "Checking: " + oi + "," + ii + " : " + cells[oi, ii].ToString()
            );
        }
    }
    

    You can then save a list of references to cells[oi, ii] contents which match your desired value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So i need to figure out how i can get a record count value
I have a piece of code where I need to figure out if a
I just need a sanity check here... DEMO Basically, I can't figure out how
Need to figure out the best way to get rid of the following problem
Can't figure out how to use bbp_get_reply_author_role(), and i really need it, returns an
I need to figure out a way to set ValidateRequest at model...I understand that
I need to figure out a way to insert a record with a java.util.Date
I need to figure out the size of a remote file before I download
I understand that I need to figure out my own homework, but seeing that
From the following HTML I need to figure out which List tag has class

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.