c#sbyte_C#中的sbyte关键字

c#sbyte

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

In C#, sbyte is a keyword which is used to declare a variable that can store a signed value between the range of -128 to +127. sbyte keyword is an alias of System.SByte.

在C#中, sbyte是关键字,用于声明一个变量,该变量可以存储-128到+127范围内的有符号值。 sbyte关键字是System.SByte的别名。

It occupies 1 byte (8 bits) in the memory.

它在内存中占用1个字节(8位)。

Syntax:

句法:

    sbyte variable_name = value;

It can store the value between the range of -128 to +127.

它可以存储介于-128到+127之间的值。

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

Here, we are declaring a sbyte variable num, initializing it with the value -120 and printing its value, type and size of a sbyte type variable.

在这里,我们声明一个sbyte变量num ,使用值-120对其进行初始化,并打印sbyte类型变量的值,类型和大小。

using System;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            //char variable declaration
            sbyte num = -120;

            //printing value
            Console.WriteLine("num: " + num);
            //printing type of variable
            Console.WriteLine("Type of num: " + num.GetType());
            //printing size of a decimal 
            Console.WriteLine("Size of a sbyte variable: " + sizeof(sbyte));

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

Output

输出量

num: -120
Type of num: System.SByte
Size of a sbyte variable: 1


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

c#sbyte

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值