Re: why does adding 2 bytes together result in an int?
- From: "Larry Lard" <larrylard@xxxxxxxxxxx>
- Date: 2 Mar 2006 09:14:25 -0800
moondaddy wrote:
my understanding is that the max value of a byte is 255. Therefore, why
does the following code get a compile error?
byte val1 = 10;
byte val2 = 23;
byte ttl;
ttl = val1 + val2; //this line wont compile
compile error: Cannot implicitly convert type 'int' to 'byte'.
val1 + val2 = 33 which is still in the range of a byte. therefore, why do I
need to convert ttl into an int?
What's 128 + 128 ?
--
Larry Lard
Replies to group please
.
- References:
- why does adding 2 bytes together result in an int?
- From: moondaddy
- why does adding 2 bytes together result in an int?
- Prev by Date: Cool Windows controls
- Next by Date: Re: SetForegroundWindow in Visual C# Express
- Previous by thread: why does adding 2 bytes together result in an int?
- Next by thread: Re: why does adding 2 bytes together result in an int?
- Index(es):
Relevant Pages
|
Loading