【问题标题】:Is it safe to assume an Integer will always be 32 bits in VB.Net?假设一个整数在 VB.Net 中总是 32 位是否安全?
【发布时间】:2011-09-26 18:34:14
【问题描述】:

相关:

Is it safe to assume an int will always be 32 bits in C#?

链接的问题询问是否“假设 int 在 C# 中始终为 32 位是安全的”。接受的答案指出“C# 规范严格定义 int 是 System.Int32 的别名,正好是 32 位”。

我的问题是:这是否适用于 VB.Net 的整数?假设 Integer 始终是 int32 的别名是否安全?

【问题讨论】:

    标签: vb.net integer alias int32


    【解决方案1】:

    VB.Net 没有“int”,它有一个“Integer”类型。 Integer 类型是 System.Int32 的别名。所以不,这不会改变。

    【讨论】:

      【解决方案2】:

      是的。
      Integer 类型永远不会改变。

      spec(7.3 原始类型)说:

      整数值类型 Byte(1 字节无符号整数)、Short(2 字节有符号整数)、Integer(4 字节有符号整数)和 Long(8 字节有符号整数)。这些类型分别映射到 System.Byte、System.Int16、System.Int32 和 System.Int64。整数类型的默认值等价于字面量 0。

      【讨论】:

      • 感谢您的链接。作为参考,它也在 VB.Net 2008 (.NET 3.5/VB 9) 规范的第 7.3 节中。
      • AFAIK,较新的规范无法在线进行深度链接(它们仅作为 Word 文档提供)
      猜你喜欢
      • 2013-08-23
      • 2012-04-24
      • 2016-12-13
      • 2021-08-25
      • 2011-02-27
      • 2010-09-19
      • 2011-05-13
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多