dotnet0824
asked on
c# code
there is a small prob with the code converted from vb to c#
---------visual basic ------------
dim j as integer
dim i as integer
for i =0 to 5
j = 2 ^ i (i being 0 in first time loop)
msgbox(j) returns 1 (ie 2 ^ 0)
next
==============cSharp====== ========== ========I want this to return 1 same as in vb
but same code in C# msgbox(j) returns 2
int j = 0;
for (int i = 0; i < 5; i++)
{
j = 2 ^ i;
Messagebox.show(j); -- j returns 2 (ie 2 ^ 0)
}
---------visual basic ------------
dim j as integer
dim i as integer
for i =0 to 5
j = 2 ^ i (i being 0 in first time loop)
msgbox(j) returns 1 (ie 2 ^ 0)
next
==============cSharp======
but same code in C# msgbox(j) returns 2
int j = 0;
for (int i = 0; i < 5; i++)
{
j = 2 ^ i;
Messagebox.show(j); -- j returns 2 (ie 2 ^ 0)
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
2 XOR 0 is equal to 2
http://msdn.microsoft.com/en-us/library/6a71f45d(VS.80).aspx