the line \"if(arg2 & 1)\" in C++(arg2 is DWORD) is equal to \"if(arg2 & 1==0)\" in C#(arg2 is Uint32),right?
I am trying to translate a function from C++ to
DWORD is uint32_t in C++, thus UInt32 in C#.if(a & b) converts to if((a & b) != 0). != is evaluated before & thus the & expression needs parentheses around it. if(x) converts to if(x != 0)& is a 'bitwise and' in C#, like in C++.Where you write :
if (arg1 & arg2==0)
The compiler understands :
if (arg1 & (arg2==0))
You should write :
if ((arg1 & arg2) == 0)
This is the way the C++ statement should be translated to C# :
if (arg2 & 1) // C++ (arg2 is DWORD)
if ((arg2 & 1) != 0) // C# (arg2 is Uint32)
Or, in a more generic way:
if (Flags & FlagToCheck) // C++
if ((Flags & FlagToCheck) != 0) // C#
In C/C++, 0 is false, everything else is true.
5 - It means both. Because LowPart and HighPart are just "windows" into QuadPart's memory, when result.LowPart == 1 and Result.HighPart == 0, then result.QuadPart will be equal to 1.