locked
How to represent binary number directly in C#? RRS feed

  • Question

  • Hello all:

     

    We could represent Oct, Hex and Dec directly in C#.

    Is it possible that we can also represent binary number in C#?

     

     

    Thank you

    -Daniel

    Code Snippet

    int x = 0x10;  // hex
    int y = 015;  // oct

     

     

    Friday, August 17, 2007 6:33 PM

Answers

  • Nay... closest thing would be to do so as a string and then convert it to a number (short of knowing ones hex quite well):

     

    Code Snippet

    int z = Convert.ToInt32("11001001", 2);

     

     

    Friday, August 17, 2007 6:39 PM

All replies