Karthikeyan Pandian wrote:
You said that casting the byte will produce the result in byte ,then
byte c =(byte)a+b; --->this statement is enough right but even though you am getting error in this line
I am only getting the output
if i cast like this
byte c = (byte)(a+b);
can you clear my doubt?
Casting has a higher precedence than the addition operator. The extra parenthesis is needed for the expression to end up as a byte (which you have already discovered).
[EDIT: and it looks like Steve beat me to the response...
]
Henry