How do you return 'not uint' in C#?

前端 未结 3 720
醉酒成梦
醉酒成梦 2021-01-23 02:56

I have some code written in VB that reads as follows:

Return (Not (crc32Result))

I am trying to convert it to C#, and this is what I have:

3条回答
  •  一整个雨季
    2021-01-23 03:43

    In C#, the bang(!) is used to flip a boolean variable. Are you trying to treat the uInt above as a boolean, or perform some other reversal (reversal of all binary digits, perhaps)?

    I'd suggest one of these is the solution you're looking for:

    return (!(bool)crc32Result);  // treating as bool (0 = false, anything else is true)
    
    return (~crc32Result); //bitwise flipping for all
    

提交回复
热议问题