Link to home
Start Free TrialLog in
Avatar of deleyd
deleydFlag for United States of America

asked on

Is a byte value signed or unsigned?

Is a byte value signed or unsigned?
byte x = 0xF4;
if (x == 244)
if (x == -11) 

Open in new window

will they both work?
ASKER CERTIFIED SOLUTION
Avatar of andrewjb
andrewjb
Flag of United Kingdom of Great Britain and Northern Ireland image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Paul Jackson
Byte variables are stored as unsigned 8-bit (1-byte) numbers ranging in value from 0 through 255
byte is an unsigned 8-bit integer, so on the example given only (x == 244) will return true.

byte (C# Reference)
http://msdn.microsoft.com/en-us/library/5bdb6693.aspx

You could have probably googled "c# byte" faster than typing in this question :-)