Skip navigation

Just cast it (int)enumVal:


enum BodyType
{
  Fat,
  Thin,
  Musclebound = 500,
  Anorexic
} ;

class Program
{
  static void Main( string[] args )
  {
    BodyType debbie = BodyType.Fat ;
    BodyType john = BodyType.Anorexic ;
    BodyType harold = BodyType.Thin ;

    Console.WriteLine( "Debbie is " + debbie + ".  Numerical value: " + (int)debbie ) ;
    Console.WriteLine( "john is " + john + ".  Numerical value: " + (int)john ) ;
    Console.WriteLine( "harold is " + harold + ".  Numerical value: " + (int)harold ) ;
  }
}
 

Advertisements

3 Comments

  1. This is not C++

  2. yes it is C#!

  3. My bad. I had tagged it with “C++” accidently – wordpress actually doesn’t let you tag with the # symbol –


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: