• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 446
  • Last Modified:

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?
0
deleyd
Asked:
deleyd
  • 2
1 Solution
 
andrewjbCommented:
Unsigned.

sbyte is signed.

So 'no' is your answer.
0
 
Paul JacksonSoftware EngineerCommented:
Byte variables are stored as unsigned 8-bit (1-byte) numbers ranging in value from 0 through 255
0
 
wdosanjosCommented:
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

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

Featured Post

Upgrade your Question Security!

Your question, your audience. Choose who sees your identity—and your question—with question security.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now