本文共 3309 字,大约阅读时间需要 11 分钟。
c# uint 和int
In C#, Int64 known as a signed integer of 8 bytes which can store both types of values including negative and positive between the ranges of -9223372036854775808 to +9223372036854775807.
在C#中, Int64被称为8字节的有符号整数,它可以存储-9223372036854775808到+9223372036854775807范围之间的两种类型的值,包括负数和正数 。
UInt64 known as an unsigned integer of 8 bytes which can store only positive values between the ranges of 0 to 18446744073709551615.
UInt64,它是8个字节的无符号整数 ,只能存储0到18446744073709551615范围之间的正值 。
Int64 | UInt64 |
---|---|
Int64 stands for signed integer. | UInt64 stands for unsigned integer. |
It's capacity to store the value is -9223372036854775808 to +9223372036854775807. | It's capacity to store the value is 0 to 18446744073709551615. |
It can store negative and positive integers. | It can store only positive integers. |
It occupies 8-bytes space in the memory. | It also occupies 8-bytes space in the memory. |
Declaration syntax:Int64 variable; | Declaration syntax:UInt64 variable; |
整数64 | UInt64 |
---|---|
Int64代表有符号整数。 | UInt64代表无符号整数。 |
它可以存储值的容量是-9223372036854775808至+9223372036854775807。 | 存储值的容量为0到18446744073709551615。 |
它可以存储负整数和正整数。 | 它只能存储正整数。 |
它在内存中占用8个字节的空间。 | 它还在内存中占用8字节的空间。 |
声明语法: Int64变量; | 声明语法: UInt64变量; |
Example:
例:
In this example, to explain the differences between Int64 and UInt64 in C#, we are printing their minimum and maximum values, we are also declaring two arrays – arr1 is a signed integer type and arr2 is an unsigned integer type. Initializing the arrays with corresponding negative and positive values based on their capacity.
在此示例中,为了解释C#中Int64和UInt64之间的区别 ,我们将打印它们的最小值和最大值,同时还声明了两个数组– arr1是有符号整数类型,而arr2是无符号整数类型。 根据其容量用相应的负值和正值初始化数组。
using System;using System.Text;namespace Test{ class Program { static void Main(string[] args) { //Int64 value range Console.WriteLine("Int64 value capacity..."); Console.WriteLine("Min: {0}, Max: {1}\n", Int64.MinValue, Int64.MaxValue); //UInt64 value range Console.WriteLine("UInt64 value capacity..."); Console.WriteLine("Min: {0}, Max: {1}\n", UInt64.MinValue, UInt64.MaxValue); //Int64 array Int64[] arr1 = { -9223372036854775808, 0, 1287822320009, 9223372036854700000, 9223372036854775807 }; Console.WriteLine("UInt64 array elements..."); foreach (Int64 num in arr1) { Console.WriteLine(num); } Console.WriteLine(); //UInt64 array UInt64[] arr2 = { 0, 1239289300, 2399900900022, 18446744073709000000, 1844674407370955161 }; Console.WriteLine("UInt64 array elements..."); foreach (UInt64 num in arr2) { Console.WriteLine(num); } //hit ENTER to exit Console.ReadLine(); } }}
Output
输出量
Int64 value capacity...Min: -9223372036854775808, Max: 9223372036854775807UInt64 value capacity...Min: 0, Max: 18446744073709551615UInt64 array elements...-92233720368547758080128782232000992233720368547000009223372036854775807UInt64 array elements...012392893002399900900022184467440737090000001844674407370955161
翻译自:
c# uint 和int
转载地址:http://jzozd.baihongyu.com/