J
Jon Slaughter
I was using ints for all my code which involved a lot of bitwise logic.
Since in actuality I was just working with bytes I decided to change all the
ints to bytes. Now none of my code works... I have to explicitly cast any
time I use a bitwise operator just because C# thinks it has to be an int.
like if I do
byte x;
x >> 3 then it must be an int, right?
or x | 5 then it must be an int and I have to explicity cast back to a byte.
for example,
byte x = 5;
byte y = x | 3;
gives
Error 1 Cannot implicitly convert type 'int' to 'byte'. An explicit
conversion exists (are you missing a cast?) C:\Documents and Settings\Jon\My
Documents\Visual Studio 2005\Projects\ThreadTest5\ThreadTest5\Program.cs 31
22 ThreadTest5
This is really ridiculous!!!!
I know one can use unchecked but its a mess and I would have about 20% of my
code being the work unchecked(because I have a lot of short properties that
just extract bits from data.
Is there any way to turn off this "feature" completely? Non of my bit
juggling produces any ints so I don't need to implicitly or explicitly cast
from an int.
Jon
Since in actuality I was just working with bytes I decided to change all the
ints to bytes. Now none of my code works... I have to explicitly cast any
time I use a bitwise operator just because C# thinks it has to be an int.
like if I do
byte x;
x >> 3 then it must be an int, right?
or x | 5 then it must be an int and I have to explicity cast back to a byte.
for example,
byte x = 5;
byte y = x | 3;
gives
Error 1 Cannot implicitly convert type 'int' to 'byte'. An explicit
conversion exists (are you missing a cast?) C:\Documents and Settings\Jon\My
Documents\Visual Studio 2005\Projects\ThreadTest5\ThreadTest5\Program.cs 31
22 ThreadTest5
This is really ridiculous!!!!
I know one can use unchecked but its a mess and I would have about 20% of my
code being the work unchecked(because I have a lot of short properties that
just extract bits from data.
Is there any way to turn off this "feature" completely? Non of my bit
juggling produces any ints so I don't need to implicitly or explicitly cast
from an int.
Jon