Q:

Get appropriate values from hexadecimal

Let's say I have to following table with values (1st row is the description)

DESCRIPTION -> DECIMAL VALUE -> BIT NUMBER 
Option1 -> 1 -> 1 
Option2 -> 2 -> 2 
Option3 -> 4 -> 3 
Option4 -> 8 -> 4

OptionX -> 137438953472 -> 38

Now I have the following value: 0x7000000800000000. How can I recognize, which options have been chosen based on that number?

A:

ulong v = 0x7000000800000000;
for( int i = 1; v != 0; ++i ) {
    if ((v & 1) != 0) Console.WriteLine(i);
    v >>= 1;
}

or use the BitVector class.

