I'm wondering why the //1
statements are accepted by the compiler and the //2
statements are not
//1
int k = 99999999;
byte l = (byte)k;
//2
byte b = 1;
int i = 10;
byte z = (byte)i+b; //compiler rejected
Type mismatch: cannot convert from int to byte using ternary operator gave me somewhat of an idea but I don't understand why the compiler can resolve the variable l
in //1
as acceptable and not i
in //2