C#数据类型

一、整数类型

类型 别名 允许的值
sbyte Systm.SByte 介于-128~127之间的整数
byte Systm.Byte 介于0~255之间的整数
short Systm.Int16 介于-32768~32767之间的整数
ushort Systm.UInt16 介于0~65535之间的整数
int Systm.Int32
介于-2^31~2^31-1之间的整数
uint Systm.UInt32 介于0~2^32-1之间的整数
long Systm.Int64 介于-2^63~2^63-1之间的整数
ulong Systm.UInt64 介于0~2^64-1之间的整数

一些变量前面的“u”是unsigned的缩写,表示不能在这些类型的变量中存储负数。

浮点数变量类型有3种:float、double、decimal

float和double用  +/-m*2^e  的形式存储浮点数

decimal 用  +/-m*10^e  的形式存储浮点数

二、浮点类型

类型 别名 m的最小值 m的最大值 e的最小值 e的最大值 近似的最小值 近似的最大值
float System.Single 0 2^24 -149 104 1.5*10^-45 3.4*10^38
double System.Double 0 2^53 -1075 970 5.0*10-324 1.7*10^308
decimal System.Decimal 0 2^96 -28 0 1.0*10^-28 7.9*10^28

三、文本和布尔类型

类型 别名 允许的值
char System.Char 一个Unicode字符,存储0~65535之间的整数
bool System.Boolean 布尔值:true或者false
string System.String 一组字符

注意:组成string的字符数量没有上限,因为它可以使用可变大小的内存

 

 

原文地址:https://www.cnblogs.com/ting5/p/4995020.html