?
Solved

How to acess Enum Array in C#

Posted on 2006-05-31
4
Medium Priority
?
1,175 Views
Last Modified: 2008-01-16
Hi experts,

I am using array of enum in my program.
And I want to pass to one of function for execution.
But I unable to know how to declare and how to pass this enu of array to function.

skeleton:

enum Sometype
{
......
};

how to declare and assign array of enum and pass to function.

I want to use as a arry in project and pass this to function.

please provide me skeleton for this passing to funtion.

Thnaks in advance
0
Comment
Question by:avinash_takale
  • 3
4 Comments
 
LVL 10

Expert Comment

by:dkloeck
ID: 16800707
You declare an enumeration type as follows:

enum someType
        {
            One,
            Two,
            Three
        }

to declare and assign an array do as follows:
to declare the array:
someType[] array1 = new someType[10];
to assign a value to one element of the array:
array1[0] = someType.One;

You can do everything as usuall using someType as type, like passing to a funktion

public void funktion(sometype mySomeTypeVariabkle)
{
...
}

good luck
0
 

Author Comment

by:avinash_takale
ID: 16800875
that really amazing .
I really  appriciated.

But can you tell me how to use thatarray in function.
i.e how to use particular value in the function

Thanks .
0
 
LVL 10

Accepted Solution

by:
dkloeck earned 500 total points
ID: 16800917
lets say you declared it as follows:

enum someType
        {
            One,
            Two,
            Three
        }

//(...)

someType[] array1 = new someType[10];
array1[0] = someType.One;
//here you can call a function
funktion(array1);

//(..)

//declaration of the funktion:
 public void function(someType[] theArray)
        {
            MessageBox.Show(theArray[0].ToString());
        }



the MessageBox will have "One" as text
0
 
LVL 10

Expert Comment

by:dkloeck
ID: 16800930
ohh.. i wrote funktion on the call and function on the declaration sorry for that =)
the declaration should be
public void funktion(someType[] theArray)
        {
            MessageBox.Show(theArray[0].ToString());
        }
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article introduced a TextBox that supports transparent background.   Introduction TextBox is the most widely used control component in GUI design. Most GUI controls do not support transparent background and more or less do not have the…
Hello there! As a developer I have modified and refactored the unit tests which was written by fellow developers in the past. On the course, I have gone through various misconceptions and technical challenges when it comes to implementation. I would…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question