Tuesday, April 22, 2014

nest an enum inside of a class in C#

namespace Whatever
{
   public class MyClass
   {
      public enum MyEnum
      {
         Foo=1,
         Bar=2,
         Baz=3,
         Qux=4
      }
   }
}

 
 

Use the enum like so:

if(MyVariable == MyClass.MyEnum.Foo)
{

No comments:

Post a Comment