hexadecimal numbers in C#
-
In C++ you can assing a variable a value of for instance 0xAAAA; I tried this in C# but it didn't work. What is the syntax like in C# when assigning a hexadecimal number? I couldn't find an example of this in books about C# which I checked, but I am sure people here know the answer to my question. Thanks! Ranger.
-
In C++ you can assing a variable a value of for instance 0xAAAA; I tried this in C# but it didn't work. What is the syntax like in C# when assigning a hexadecimal number? I couldn't find an example of this in books about C# which I checked, but I am sure people here know the answer to my question. Thanks! Ranger.
It works in c# too. ShellAPI constants[^]
Giorgi Dalakishvili #region signature my articles #endregion
-
In C++ you can assing a variable a value of for instance 0xAAAA; I tried this in C# but it didn't work. What is the syntax like in C# when assigning a hexadecimal number? I couldn't find an example of this in books about C# which I checked, but I am sure people here know the answer to my question. Thanks! Ranger.
-
DaveyM69 wrote:
int x = 0xAAAA;
Thanks, I wondered... I think my error message was caused by the fact that I didn't know how many 'A's fit into a short type number. Ranger
Ranger49 wrote:
I think my error message was caused by the fact that I didn't know how many 'A's fit into a short type number.
Guess you know now ;P short = 2 bytes int = 4 bytes long = 8 bytes
xacc.ide - now with TabsToSpaces support
IronScheme - 1.0 alpha 4a out now (29 May 2008) -
DaveyM69 wrote:
int x = 0xAAAA;
Thanks, I wondered... I think my error message was caused by the fact that I didn't know how many 'A's fit into a short type number. Ranger
Ranger49 wrote:
I think my error message was caused by the fact that I didn't know how many 'A's fit into a short type number.
Don't forget to pay attention to whether that
short
number is signed or unsigned!short a = 0x7AAA; // OK!
short b = 0xAAAA; // Doh! Won't work!
ushort c = 0xAAAA; // OK!You can also use the 'unchecked' syntax to force it to be a signed short.
short x = unchecked((short)0xAAAA); // Also OK!