Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR CSHARP

c# byte + byte is int

byte i = 10;
byte k = 25;
//The below returns an int
Console.WriteLine((i + k).GetType());
//This is because of number promotion and the fact that all integral types
//below 32 bits don't seem to have their respective arithmetic operators
Console.WriteLine((byte)(i + k));
//Seems your stuck with this ^^. Which unfortunately doesn't detect overflow
 
PREVIOUS NEXT
Tagged: #byte #byte #int
ADD COMMENT
Topic
Name
7+2 =