加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

这个代字号在C#中的目的是什么

发布时间:2020-12-15 23:31:11 所属栏目:百科 来源:网络整理
导读:参见英文答案 What does the tilde mean in an expression? ????????????????????????????????????6个 我正在尝试移植这个C#代码: public static ulong WILDCARD_COLLISION_TYPE{ get { int parse = ~0; return (ulong)parse; }} 如果我理解正确,那么?符号
参见英文答案 > What does the tilde mean in an expression? ????????????????????????????????????6个
我正在尝试移植这个C#代码:

public static ulong WILDCARD_COLLISION_TYPE
{
    get
    {
        int parse = ~0;
        return (ulong)parse;
    }
}

如果我理解正确,那么?符号不会执行按位补码,那么?0的作用点是什么?然后归还呢?

解决方法

~ Operator documentation:

The ~ operator performs a bitwise complement operation on its operand,which has the effect of reversing each bit. Bitwise complement operators are predefined for int,uint,long,and ulong.

例如:

unsigned int i = ~0;

Result: Max number I can assign to i

and

signed int y = ~0;

Result: -1

所以更多信息我们可以说~0只是一个int,所有位都设置为1.当解释为unsigned时,这将等同于UINT_MAX.当解释为signed时,这将是-1

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读