Re: why does adding 2 bytes together result in an int?
- From: Jon Skeet [C# MVP] <skeet@xxxxxxxxx>
- Date: Thu, 2 Mar 2006 21:14:28 -0000
Kevin Spencer <kevin@xxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
This is because the devleopers of the platform have decided that the return
type of the + operator for the byte type should be an integer.
Not quite. There *aren't* any + operators for the byte type. These are
the integer addition operators:
int operator +(int x, int y);
uint operator +(uint x, uint y);
long operator +(long x, long y);
ulong operator +(ulong x, ulong y);
When it looks like you're adding two bytes, you're actually implicitly
converting each of them to an integer, then adding the two integers
together.
--
Jon Skeet - <skeet@xxxxxxxxx>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
.
- Follow-Ups:
- 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?
- References:
- why does adding 2 bytes together result in an int?
- From: moondaddy
- Re: why does adding 2 bytes together result in an int?
- From: Kevin Spencer
- why does adding 2 bytes together result in an int?
- Prev by Date: Re: SetForegroundWindow in Visual C# Express
- Next by Date: Re: SQL Connection String using Domain Account
- Previous by thread: Re: 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
|