PDA

Click to See Complete Forum and Search --> : Static class problems


venerable bede
Nov 10th, 2006, 03:31 AM
I am struggling to get my pea brain around this one.

I want to create a static class which holds an enumeration. Something like :


Static class enumTypes
{

public enum choice
{
choice1, choice2
}

}

I want to be able to do something like this :


If (myThingy = enumTypes.choice.choice1)
{
//do something
}
else
{
//do something else
}


The exact syntax is troubling me because I am silly.

Pirate
Nov 10th, 2006, 05:43 AM
Syntax is fine , what's the error message ?

jmcilhinney
Nov 10th, 2006, 08:11 AM
I strongly recommend that you don't do that. How many enumerations can you name in the .NET Framework that are nested within a class? None that I'm aware of. An enumeration should be declared as a member of the appropriate namespace and that's it.

As for your code, a single '=' in C# is an assignment. For comparisons use the double '=='.

Pirate
Nov 10th, 2006, 12:28 PM
oops !