So I'm trying to set a byte based on a boolean value I'm receiving from a view. I want to do it inline so it looks neater but for some reason it throws an "Cannot implicitly convert type int to byte" but when I try it with the traditional if else statement, it is working fine.
Can someone explain to me why this is happening?
byte byteFlag1;
byteFlag1 = boolFlag ? 1 : 0;
// this throws an error
byte byteFlag2;
if( boolFlag )
{
byteFlag2= 1;
} else
{
byteFlag2= 0;
}
// this works fine?