基元类型

基元类型

什么是基元类型?
编译器直接支持的数据类型

C#基元类型

FCL类型

符合CLS

说明

Sbyte

System.SByte

有符号8位值

byte

System.Byte

无符号8位值

Short

System.Int16

有符号16位值

Ushort

System.UInt16

无符号16位值

Int

System.Int32

有符号32位值

uint

System.UInt32

无符号32位值

long

System.Int64

有符号64位值

ulong

System.Uint64

无符号64位值

char

System.Char

16位Unicode字符(char不像在非托管c++zhong那样代表一个8位值)

float

System.Singe

IEEE32位浮点值

double

System.Double

IEEE64位浮点值

decimal

System.Decimal

128位高精度浮点值,常用于不容许舍入差的金融计算。128位中,1位是符号,96位是值本身(N),8位是比例因子(k)

string

System.String

字符数组

object

System.Object

所有类型的基类型

dynamic

System.Object

对于CLR,dynam和object完全一致。但C#编译器允许使用简单的语法当dynamic变量参与动态调度

可以认为C#编译器自动假定所有源代码文件都添加了一下using指令

using sbyte=System.SByte;

using int=System.Int32

...