为什么 Int64.MaxValue 返回 Long?

发布于 2024-12-13 02:27:21 字数 241 浏览 0 评论 0原文

呵呵,这很讽刺,今天玩的时候我想知道是否可以以某种方式增加 Int64.MaxValue ,结果发现 Int64.MaxValue 不是 Int64 而是 Long 。

这是为什么,这是否意味着如果我像 Int64 myInt = Int64.MaxValue; 那样存储,那么 myInt 仍将是 Int 或者它将变成 Long ,存储 Long 而不是 Int64 在此字段。

Huh that's ironic ,while playing around today i wondered if a can Increase Int64.MaxValue on some way ,and just founded out that Int64.MaxValue isn't an Int64 but a Long .

Why is that ,does it mean if i store like Int64 myInt = Int64.MaxValue; than myInt will be still an Int or it will become a Long ,what's the purpose of storing a Long Instead of Int64 at this Field .

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(6

虫児飞 2024-12-20 02:27:21

因为Int64和long是同一类型。

Int64 = long    
Int32 = int    
Int16 = short

Because Int64 and long are same type.

Int64 = long    
Int32 = int    
Int16 = short
牵你手 2024-12-20 02:27:21

long 只是 Int64 的别名。请参阅此处

long is just an alias for Int64. See here.

第几種人 2024-12-20 02:27:21

从语言规范来看:

简单类型的成员直接对应于简单类型别名的结构类型的成员:

long 的成员是 System.Int64 结构的成员。

您可以在第 3.4.2 节中查看其他别名。

从 4.1.4 开始:

C# 提供了一组称为简单类型的预定义结构类型。简单类型是通过保留字来标识的,但这些保留字只是系统命名空间中预定义结构类型的别名,如下表所述。

Reserved word Aliased type
long          System.Int64

From the language specification:

The members of a simple type correspond directly to the members of the struct type aliased by the simple type:

• The members of long are the members of the System.Int64 struct.

You can see additional aliases in §3.4.2.

And from 4.1.4:

C# provides a set of predefined struct types called the simple types. The simple types are identified through reserved words, but these reserved words are simply aliases for predefined struct types in the System namespace, as described in the table below.

Reserved word Aliased type
long          System.Int64
夜吻♂芭芘 2024-12-20 02:27:21

Int64 很长:

        Type t1 = typeof(Int64);
        Type t2 = typeof(long);
        bool same = t1.Equals(t2);  // true

查看 MSDN:

http://msdn.microsoft.com/ en-us/library/ya5y69ds.aspx

Int64 is a long:

        Type t1 = typeof(Int64);
        Type t2 = typeof(long);
        bool same = t1.Equals(t2);  // true

Check out MSDN:

http://msdn.microsoft.com/en-us/library/ya5y69ds.aspx

み青杉依旧 2024-12-20 02:27:21

Int16Int32Int64 别名为 shortint、和 long 分别。请注意,该数字是用于存储该值的位数。

There's Int16, Int32, and Int64 that are aliased to short, int, and long respectively. Note that the number is how many bits are used to store the value.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文