±èÀçȲ said:
//this code generates the error.
uint a=1,b=2;
Console.WriteLine(a << b);
Console.WriteLine(a >> b);
What problem does "uint type" have.?
The shift operators are as follows:
int operator <<(int x, int count);
uint operator <<(uint x, int count);
long operator <<(long x, int count);
ulong operator <<(ulong x, int count);
int operator >>(int x, int count);
uint operator >>(uint x, int count);
long operator >>(long x, int count);
ulong operator >>(ulong x, int count);
Note that the second parameter is *always* an int, never a uint.
So, if you change your code to:
uint a=1;
int b=2;
Console.WriteLine(a << b);
Console.WriteLine(a >> b);
it should be fine.