473,406 Members | 2,710 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Hex assignment Error???

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
Nov 16 '05 #1
4 8162
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
"Darryn Ross" <da****@datawave.com.au> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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

Nov 16 '05 #2
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

"Michael C" <mi******@nospam.org> wrote in message
news:ZE*********************@news4.srv.hcvlny.cv.n et...
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
"Darryn Ross" <da****@datawave.com.au> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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


Nov 16 '05 #3
Try this,
Int32 a = 0x20;

a = 32; //decimal

"Darryn Ross" <da****@datawave.com.au> wrote in message
news:uX**************@TK2MSFTNGP12.phx.gbl...
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

"Michael C" <mi******@nospam.org> wrote in message
news:ZE*********************@news4.srv.hcvlny.cv.n et...
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
"Darryn Ross" <da****@datawave.com.au> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
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



Nov 16 '05 #4
Darryn Ross <da****@datawave.com.au> wrote:
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;

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Peter Nofelt | last post by:
Hey all, I am running into an issue. My situation is that I wish to copy the contents of one listbox to an array, sort it by innerText value, and write the sorted options into a new listbox. ...
1
by: Raghuram N K | last post by:
Hi, Following program compiles and executes successfully in windows with DevCPP compiler. When I compile the same in Linux with 'g++323' compiler I get following assignment error: cannot...
4
by: mdh | last post by:
May I ask why this works: given: char s; char *posbfr = s; char *endbfr = s + MAXOP; void(...){ if (posbfr >= endbfr) printf("......");
1
by: dewi | last post by:
Dear All, I am trying to compile a C code using Visual C++. Can anyone explain how to solve it? Thank You. #include <math.h> #include <string.h> #include "RV2AJFRONT_NEW.h" #include...
12
by: shing | last post by:
Can anyone tell me why I'm getting a "non-lvalue in assignment" error in my C++ program? Errors are at line 30, 31 and 32. //Voltage dividing circuit calculator!!! // In series! #include...
2
by: kardon33 | last post by:
I am getting a "error: incompatible types in assignment" error and cant figure out why? I am trying to set lastRow to row at the end of the code snippet. int row; int lastRow; size_t...
1
by: kreda | last post by:
I'm trying to write a program for sorting students by their names with structures and pointers, but I get messages in lines 34 and 35 "non-lvalue in assignment".Here is the code and image. And I...
3
by: jeyshree | last post by:
hai, will someone please explain me what is null pointer assignment error.different persons say different reasons.some says the following code would generate null pointer assignment error....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.