Results 1 to 2 of 2

Thread: how can I parse an enum from its value?

  1. #1

    Thread Starter
    l33t! MrPolite's Avatar
    Join Date
    Sep 2001
    Posts
    4,428

    how can I parse an enum from its value?

    say I have this:
    enum ABC {a,b,c}

    and I have int val =2.... how can I convert the integer value to the correct enum member in ABC?
    I tried (ABC) val but it didnt work I dunno what I'm doing, someone help me
    rate my posts if they help ya!
    Extract thumbnail without reading the whole image file: (C# - VB)
    Apply texture to bitmaps: (C# - VB)
    Extended console library: (VB)
    Save JPEG with a certain quality (image compression): (C# - VB )
    VB.NET to C# conversion tips!!

  2. #2
    Hyperactive Member Hampster's Avatar
    Join Date
    Feb 2001
    Location
    On my hamster wheel.
    Posts
    374
    PHP Code:
    enum ABC {a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z
    PHP Code:
    Console.WriteLine("Give me a number 0-25 and I'll give you the letter: ");
    int x=Convert.ToInt16(Console.ReadLine());
    ABC e=(ABC)x;
    Console.WriteLine(Convert.ToInt16(e)+"="+e.ToString()); 

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width