什么是C#?

Pat*_*ers 1 c# syntax operators bitwise-operators tilde

可能重复:
C#枚举中的波浪号(〜)是多少?
波形符在表达式中意味着什么?

我从C#下载了一个CRC代码片段,其中包含以下几行:

byte[] hashBuffer = UInt32ToBigEndianBytes(~hash);
Run Code Online (Sandbox Code Playgroud)

要么

public static UInt32 Compute(byte[] buffer)
{
   return ~CalculateHash(InitializeTable(DefaultPolynomial), DefaultSeed, buffer, 0, buffer.Length);
}
Run Code Online (Sandbox Code Playgroud)

Fre*_*jon 7

〜运算符对其操作数执行按位补码运算,具有反转每个位的效果.为int,uint,long和ulong预定义了按位补码运算符.

来自:http://msdn.microsoft.com/en-us/library/d2bd4x66.aspx

虽然在您演示的示例中没有使用这种方式,但该~字符用于在C#中声明析构函数.


归档时间:

查看次数:

4185 次

最近记录:

12 年,9 月 前