c# ushort_C#中的ushort关键字

c# ushort

C#ushort关键字 (C# ushort keyword)

In C#, ushort is a keyword which is used to declare a variable that can store an unsigned integer value between the range of 0 to 65,535. ushort keyword is an alias of System.UInt16.

在C#中, ushort是一个关键字,用于声明一个变量,该变量可以存储介于0到65,535之间的无符号整数值。 ushort关键字是System.UInt16的别名。

It occupies 2 bytes (16 bits) space in the memory.

它在内存中占用2个字节(16位)的空间。

Syntax:

句法:

    ushort variable_name = value;

C#代码演示ushort关键字示例 (C# code to demonstrate example of ushort keyword)

Here, we are declaring an ushort variable num, initializing it with the value 12345 and printing its value, type and size of an ushort type variable.

在这里,我们宣布一个USHORT变量num,与价值12345初始化它和打印的USHORT类型变量它的价值,类型和大小。

using System;
using System.Text;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            //variable declaration
            ushort 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 ushort variable: " + sizeof(ushort));
            //printing minimum & maximum value of ushort
            Console.WriteLine("Min value of ushort: " + ushort.MinValue);
            Console.WriteLine("Max value of ushort: " + ushort.MaxValue);

            //hit ENTER to exit
            Console.ReadLine();
        }
    }
}

Output

输出量

num: 12345
Type of num: System.UInt16
Size of a ushort variable: 2
Min value of ushort: 0
Max value of ushort: 65535


翻译自: https://www.includehelp.com/dot-net/ushort-keyword-in-c-sharp.aspx

c# ushort

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值