c# 字节往前移6个字节_C#中字节与字节之间的差异

c# 字节往前移6个字节

C#字节和C#字节 (C# byte and C# sbyte)

A single byte can store 8-bits value. Both are used for byte type of data i.e. the data that contains an only 1-byte value.

一个字节可以存储8位值。 两者均用于字节类型的数据,即仅包含1字节值的数据。

byte is used to work with unsigned byte data, it works with an only positive value between in the range of 0 to 255.

byte用于处理无符号字节数据 ,它的唯一正值在0到255之间

sbyte is used to work with the signed byte data, it works with both types of data (Negative and Positive), it can store the between in the range of -128 to 127.

sbyte用于处理带符号的字节数据 ,它适用于两种类型的数据(负数据和正数据),它可以存储介于-128到127之间的数据

“字节”和“字节”之间的区别 (Differences between 'byte' and 'sbyte')

bytesbyte
byte stands for unsigned byte.sbyte stands for signed byte.
It can store positive bytes only.It can store negative and positive bytes.
It takes 8-bits space in the memory.It also takes the 8-bits in the memory.
Its data range is 0 to 255 that means it can store a minimum value 0 and maximum upto 255.Its data range is -128 to 127 that means it can store a minimum value -128 and maximum upto 127.
Declaration syntax:
byte variable;
Declaration syntax:
sbyte variable;
字节 兆字节
byte代表无符号字节。 sbyte代表有符号字节。
它只能存储正字节。 它可以存储负字节和正字节。
它在内存中占用8位空间。 它还占用存储器中的8位。
它的数据范围是0到255,这意味着它可以存储最小值0和最大值,最多255。 它的数据范围是-128到127,这意味着它可以存储最小值-128和最大值,最多127。
声明语法:
字节变量;
声明语法:
sbyte变量;

Example:

例:

Declaring signed and unsigned byte variable, assigning them with the values and printing the values.

声明有符号和无符号字节变量,为它们分配值并打印值。

using System;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            byte a;
            sbyte b;

            //printing minimum & maximum values
            Console.WriteLine("Minimum value of byte: " + byte.MinValue);
            Console.WriteLine("Maximum value of byte: " + byte.MaxValue);

            Console.WriteLine("Minimum value of sbyte: " + sbyte.MinValue);
            Console.WriteLine("Maximum value of sbyte: " + sbyte.MaxValue);
            a = 0;
            Console.WriteLine("a = " + a);
            a = 255;
            Console.WriteLine("a = " + a);

            b = -100;
            Console.WriteLine("b = " + b);
            
            b = 123;
            Console.WriteLine("b = " + b);
            
            b = 127;
            Console.WriteLine("b = " + b);


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

Output

输出量

Minimum value of byte: 0
Maximum value of byte: 255
Minimum value of sbyte: -128
Maximum value of sbyte: 127
a = 0
a = 255
b = -100
b = 123
b = 127

Read more:

阅读更多:

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

c# 字节往前移6个字节

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值