相关疑难解决方法(0)

如何在C#中使用&运算符?代码的翻译是否正确?

C++中的"if(arg2&1)"行(arg2是DWORD)等于C#中的"if(arg2&1 == 0)"(arg2是Uint32),对吧?

我正在尝试将函数从C++转换为C#,但是我收到一个错误:

Operator '&' cannot be applied to operands of type 'uint' and 'bool'
Run Code Online (Sandbox Code Playgroud)

如果你能在整个功能中看到任何其他错误,我也会感激不尽.

C++

DWORD Func_X_4(DWORD arg1, DWORD arg2, DWORD arg3)
{
LARGE_INTEGER result = {1, 0};
LARGE_INTEGER temp1 = {0};
LARGE_INTEGER temp2 = {0};
LARGE_INTEGER temp3 = {0};
LARGE_INTEGER temp4 = {0};
for(int x = 0; x < 32; ++x)
{
    if(arg2 & 1)
    {
        temp1.LowPart = arg3;
        temp1.HighPart = 0;
        temp2.QuadPart = temp1.QuadPart * result.QuadPart;
        temp3.LowPart = arg1;
        temp3.HighPart = 0;
        temp4.QuadPart = temp2.QuadPart …
Run Code Online (Sandbox Code Playgroud)

c# operators bitwise-operators conditional-statements

3
推荐指数
1
解决办法
1万
查看次数