Hex assignment Error???

  • Thread starter Thread starter Darryn Ross
  • Start date Start date
D

Darryn Ross

Hi

Why can't i assign the following value to a integer constant?
private const int WM_KEYDOWN = &H100 ;

the error message i am getting is C:\Dev\Cls.cs(99): The name 'H100' does
not exist in the class or namespace 'MyDLL.MyClass'

Regards

Darryn
 
Probably because Hexadecimal Integer Literals in C# are defined as "0x"
followed by a hexadecimal constant. In C#, &H100 is the unary operator that
returns the "address of" the variable "H100", which you apparently haven't
defined as a variable. C# has a different syntax from VB.

Thanks,
Michael C., MCDBA
 
Ok... so the assignment i am trying to make is wrong. See i took a Vb
example and converted it to C# but i am not sure how to make this assignment
in C# for this const.

How do i assign the int the hexadecimal value?

Thanks
 
Try this,
Int32 a = 0x20;

a = 32; //decimal

Darryn Ross said:
Ok... so the assignment i am trying to make is wrong. See i took a Vb
example and converted it to C# but i am not sure how to make this assignment
in C# for this const.

How do i assign the int the hexadecimal value?

Thanks
 
Darryn Ross said:
Ok... so the assignment i am trying to make is wrong. See i took a Vb
example and converted it to C# but i am not sure how to make this assignment
in C# for this const.

How do i assign the int the hexadecimal value?

As Michael said, use 0x:

private const int WM_KEYDOWN = 0x100;
 
Back
Top