C#ulong关键字 (C# ulong keyword)
In C#, ulong is a keyword which is used to declare a variable that can store an unsigned integer value between the range of 0 to 18,446,744,073,709,551,615. ulong keyword is an alias of System.UInt64.
在C#中, ulong是一个关键字,用于声明一个变量,该变量可以存储介于0到18,446,744,073,709,551,615之间的无符号整数值。 ulong关键字是System.UInt64的别名。
It occupies 8 bytes (64 bits) space in the memory.
它在内存中占用8个字节(64位)的空间。
Syntax:
句法:
ulong variable_name = value;
C#代码演示ulong关键字示例 (C# code to demonstrate example of ulong keyword)
Here, we are declaring an ulong variable num, initializing it with the value 12345 and printing its value, type and size of an ulong type variable.
在这里,我们宣布一个ULONG变量num,与价值12345初始化它与印刷ULONG类型的变量它的价值,类型和大小。
using System;
using System.Text;
namespace Test
{
class Program
{
static void Main(string[] args)
{
//variable declaration
ulong num = 12345;
//printing value
Console.WriteLine("num: " + num);
//printing type of variable
Console.WriteLine("Type of num: " + num.GetType());
//printing size
Console.WriteLine("Size of a ulong variable: " + sizeof(ulong));
//printing minimum & maximum value of ulong
Console.WriteLine("Min value of ulong: " + ulong.MinValue);
Console.WriteLine("Max value of ulong: " + ulong.MaxValue);
//hit ENTER to exit
Console.ReadLine();
}
}
}
Output
输出量
num: 12345
Type of num: System.UInt64
Size of a ulong variable: 8
Min value of ulong: 0
Max value of ulong: 18446744073709551615
翻译自: https://www.includehelp.com/dot-net/ulong-keyword-in-c-sharp.aspx