c# 整数类型转byte_C#中数据类型的整数类型
c# 整數(shù)類型轉byte
Here is the list of the built-in integral types of data types in C#, sbyte, byte, char, short, ushort, int, uint, long and ulong
這是C#, sbyte , byte , char , short , ushort , int , int , uint , long和ulong中數(shù)據(jù)類型的內置整數(shù)類型的列表
C#數(shù)據(jù)類型的積分類型 (C# Integral types of Data types)
.tbl-temp tr th{background-color: #006969; color: #fff;}.tbl-temp a, a:visited{color: #006969;font-weight: 500;text-decoration: none;}.tbl-temp a:hover{text-decoration: underline;} .tbl-temp tr th{background-color: #006969; color: #fff;}.tbl-temp a, a:visited{color: #006969;font-weight: 500;text-decoration: none;}.tbl-temp a:hover{text-decoration: underline;}| sbyte | System.SByte | 8-bits | -128 to 127 | Signed integer |
| byte | System.Byte | 8-bits | 0 to 255 | Unsigned integer |
| char | System.Char | 16-bits | U+0000 to U+ffff | Unicode character |
| short | System.Int16 | 16-bits | -32,768 to 32,767 | Signed integer |
| ushort | System.Int16 | 16-bits | 0 to 65,535 | Unsigned integer |
| int | System.Int32 | 32-bits | -2,147,483,648 to 2,147,483,647 | Signed integer |
| uint | System.Int32 | 32-bits | 0 to 4,294,967,295 | Unsigned integer |
| long | System.Int64 | 64-bits | -9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 | Signed integer |
| ulong | System.Int64 | 64-bits | 0 to 18,446,744,073,709,551,615 | Unsigned integer |
| 兆字節(jié) | 系統(tǒng)字節(jié) | 8位 | -128至127 | 有符號整數(shù) |
| 字節(jié) | 系統(tǒng)字節(jié) | 8位 | 0至255 | 無符號整數(shù) |
| 燒焦 | 系統(tǒng)字符 | 16位 | U + 0000至U + ffff | Unicode字符 |
| 短 | System.Int16 | 16位 | -32,768至32,767 | 有符號整數(shù) |
| 超短 | System.Int16 | 16位 | 0至65,535 | 無符號整數(shù) |
| 整型 | System.Int32 | 32位 | -2,147,483,648至2,147,483,647 | 有符號整數(shù) |
| int | System.Int32 | 32位 | 0至4,294,967,295 | 無符號整數(shù) |
| 長 | System.Int64 | 64位 | -9,223,372,036,854,775,808至9,223,372,036,854,775,807 | 有符號整數(shù) |
| 烏龍 | System.Int64 | 64位 | 0至18,446,744,073,709,551,615 | 無符號整數(shù) |
Example:
例:
In this example, we are declaring variables of different integral types of data types, initializing with the different value, printing the system types of the variables, size of the types and min, max values of the types.
在此示例中,我們聲明了不同整數(shù)類型的數(shù)據(jù)類型的變量,使用不同的值進行初始化,打印了變量的系統(tǒng)類型,類型的大小以及類型的最小值,最大值。
using System; using System.Text;namespace Test {class Program{static void Main(string[] args){//sbytesbyte a = -10;Console.WriteLine("sbyte...");Console.WriteLine("a = " + a);Console.WriteLine("type of variable = " + a.GetType());Console.WriteLine("size of sbyte = " + sizeof(sbyte));Console.WriteLine("Min value of sbyte = " + sbyte.MinValue);Console.WriteLine("Max value of sbyte = " + sbyte.MaxValue);Console.WriteLine();//bytebyte b = 10;Console.WriteLine("byte...");Console.WriteLine("b = " + b);Console.WriteLine("type of variable = " + b.GetType());Console.WriteLine("size of byte = " + sizeof(byte));Console.WriteLine("Min value of byte = " + byte.MinValue);Console.WriteLine("Max value of byte = " + byte.MaxValue);Console.WriteLine();//charchar c = 'P';Console.WriteLine("char...");Console.WriteLine("c = " + c);Console.WriteLine("type of variable = " + c.GetType());Console.WriteLine("size of char = " + sizeof(char));Console.WriteLine("Min value of char = " + (int)(char.MinValue));Console.WriteLine("Max value of char = " + (int)(char.MaxValue));Console.WriteLine();//shortshort d = -18910;Console.WriteLine("short...");Console.WriteLine("d = " + d);Console.WriteLine("type of variable = " + d.GetType());Console.WriteLine("size of short = " + sizeof(short));Console.WriteLine("Min value of short = " + short.MinValue);Console.WriteLine("Max value of short = " + short.MaxValue);Console.WriteLine();//ushortushort e = 18910;Console.WriteLine("ushort...");Console.WriteLine("e = " + e);Console.WriteLine("type of variable = " + e.GetType());Console.WriteLine("size of ushort = " + sizeof(short));Console.WriteLine("Min value of ushort = " + ushort.MinValue);Console.WriteLine("Max value of ushort = " + ushort.MaxValue);Console.WriteLine();//intint f = -893818910;Console.WriteLine("int...");Console.WriteLine("f = " + f);Console.WriteLine("type of variable = " + f.GetType());Console.WriteLine("size of int = " + sizeof(int));Console.WriteLine("Min value of int = " + int.MinValue);Console.WriteLine("Max value of int = " + int.MaxValue);Console.WriteLine();//uintint g = 893818910;Console.WriteLine("uint...");Console.WriteLine("g = " + g);Console.WriteLine("type of variable = " + g.GetType());Console.WriteLine("size of uint = " + sizeof(uint));Console.WriteLine("Min value of uint = " + uint.MinValue);Console.WriteLine("Max value of uint = " + uint.MaxValue);Console.WriteLine();//longlong h = -90909893818910;Console.WriteLine("long...");Console.WriteLine("h = " + h);Console.WriteLine("type of variable = " + h.GetType());Console.WriteLine("size of long = " + sizeof(long));Console.WriteLine("Min value of long = " + long.MinValue);Console.WriteLine("Max value of long = " + long.MaxValue);Console.WriteLine();//ulongulong i = 90909893818910;Console.WriteLine("ulong...");Console.WriteLine("i = " + i);Console.WriteLine("type of variable = " + i.GetType());Console.WriteLine("size of ulong = " + sizeof(ulong));Console.WriteLine("Min value of ulong = " + ulong.MinValue);Console.WriteLine("Max value of ulong = " + ulong.MaxValue);Console.WriteLine();//hit ENTER to exitConsole.ReadLine();}} } .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}} .minHeight{min-height: 250px;}@media (min-width: 1025px){.minHeight{min-height: 90px;}}Output
輸出量
sbyte... a = -10 type of variable = System.SByte size of sbyte = 1 Min value of sbyte = -128 Max value of sbyte = 127byte... b = 10 type of variable = System.Byte size of byte = 1 Min value of byte = 0 Max value of byte = 255char... c = P type of variable = System.Char size of char = 2 Min value of char = 0 Max value of char = 65535short... d = -18910 type of variable = System.Int16 size of short = 2 Min value of short = -32768 Max value of short = 32767ushort... e = 18910 type of variable = System.UInt16 size of ushort = 2 Min value of ushort = 0 Max value of ushort = 65535int... f = -893818910 type of variable = System.Int32 size of int = 4 Min value of int = -2147483648 Max value of int = 2147483647uint... g = 893818910 type of variable = System.Int32 size of uint = 4 Min value of uint = 0 Max value of uint = 4294967295long... h = -90909893818910 type of variable = System.Int64 size of long = 8 Min value of long = -9223372036854775808 Max value of long = 9223372036854775807ulong... i = 90909893818910 type of variable = System.UInt64 size of ulong = 8 Min value of ulong = 0 Max value of ulong = 18446744073709551615Ref: Integral types table
參考: 整體類型表
翻譯自: https://www.includehelp.com/dot-net/integral-types-of-data-types-in-c-sharp.aspx
c# 整數(shù)類型轉byte
總結
以上是生活随笔為你收集整理的c# 整数类型转byte_C#中数据类型的整数类型的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 颐和园晚上几点关门时间
- 下一篇: 二进制文件签名_二进制数的签名表示