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

vb.net – 如何在ULong上使用按位运算设置大常量?

发布时间:2020-12-17 07:16:44 所属栏目:百科 来源:网络整理
导读:这很好用: Public Const test As ULong = 1 30 这不能很好地工作: Public Const test As ULong = 1 31 它会创建此错误: Constant expression not representable in type ‘ULong’ 我如何使其工作? 这确实有效: Public Const test As Long = 1 31 但我
这很好用:

Public Const test As ULong = 1 << 30

这不能很好地工作:

Public Const test As ULong = 1 << 31

它会创建此错误:

Constant expression not representable in type ‘ULong’

我如何使其工作?

这确实有效:

Public Const test As Long = 1 << 31

但我必须使用ULong.

解决方法

请尝试以下方法:

Public Const test As ULong = 1UL << 31

您需要明确告诉编译器您正在对ULong进行操作.

C#等效工作:

public const ulong test  = 1UL << 31;

(编辑:李大同)

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

    推荐文章
      热点阅读