why does adding 2 bytes together result in an int?
- From: "moondaddy" <moondaddy@xxxxxxxxxxxxx>
- Date: Thu, 2 Mar 2006 11:10:01 -0600
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?
Thanks.
--
moondaddy@xxxxxxxxxxxxx
.
- Follow-Ups:
- Re: why does adding 2 bytes together result in an int?
- From: Nick Hounsome
- Re: why does adding 2 bytes together result in an int?
- From: Kevin Spencer
- Re: why does adding 2 bytes together result in an int?
- From: Larry Lard
- Re: why does adding 2 bytes together result in an int?
- Prev by Date: Re: Question about the max length of a TextBox control
- Next by Date: Cool Windows controls
- Previous by thread: Re: Question about the max length of a TextBox control
- Next by thread: Re: why does adding 2 bytes together result in an int?
- Index(es):
Relevant Pages
|