Question of The bitwise or operator

  • Thread starter Thread starter ±èÀçȲ
  • Start date Start date
±

±èÀçȲ

Why does follwing code generates the error..?

ulong a = 3;
int b = 15;
Console.WriteLine(a | b);
 
There isn't an implicit conversion between int and ulong. Therefore, you
have to cast the int to ulong.

Console.WriteLine(a | (ulong)b);

Joe
 
Back
Top