can someone please explain why one needs a larger data type for the result variable in C# as in the code below
the result of any logical operation never results in a larger number, why the need for one? i tried to compile using result as byte and got "Cannot implicitly convert type 'int' to 'byte'" error.Code:using System; class MyClass { public static void Main() { byte varA=10;// binary equivalent for 10 is 00001010 byte varB=20;// binary equivalent for 20 is 00010100 int result=varA & varB; // AND operation result should be 00000000 }
luigi



LinkBack URL
About LinkBacks


