c#中的数据类型

weblog 3062 0 0
c#中的数据类型

c#中的  数据类型分为值类型引用类型 

值类型有包括(结构体类型,枚举类型)              

引用类型又包括(类类型,数组类型,接口类型,委托类型

c#数据类型的派生谱系

值类型

值类型变量可以直接分配给一个值。它们是从类 System.ValueType 中派生的。

值类型直接包含数据。比如 int、char、float,它们分别存储数字、字符、浮点数。当您声明一个 int 类型时,系统分配内存来存储值。

类型 描述 范围 默认值
bool 布尔值 True 或 False False
byte 8 位无符号整数 0 到 255 0
char 16 位 Unicode 字符 U +0000 到 U +ffff '\0'
decimal 128 位精确的十进制值,28-29 有效位数 (-7.9 x 1028 到 7.9 x 1028) / 100 到 28 0.0M
double 64 位双精度浮点型 (+/-)5.0 x 10-324 到 (+/-)1.7 x 10308 0.0D
float 32 位单精度浮点型 -3.4 x 1038 到 + 3.4 x 1038 0.0F
int 32 位有符号整数类型 -2,147,483,648 到 2,147,483,647 0
long 64 位有符号整数类型 -9,223,372,036,854,775,808 到 9,223,372,036,854,775,807 0L
sbyte 8 位有符号整数类型 -128 到 127 0
short 16 位有符号整数类型 -32,768 到 32,767 0
uint 32 位无符号整数类型 0 到 4,294,967,295 0
ulong 64 位无符号整数类型 0 到 18,446,744,073,709,551,615 05
ushort 16 位无符号整数类型 0 到 65,535 0
引用类型

引用类型不包含存储在变量中的实际数据,但它们包含对变量的引用。

换句话说,它们指的是一个内存位置。使用多个变量时,引用类型可以指向一个内存位置。如果内存位置的数据是由一个变量改变的,其他变量会自动反映这种值的变化。内置的 引用类型有:object、dynamic 和 string。

int和Int32的关系

int关键字是 System 命名空间中的预定义类型System.Int32的别名。

MSDN上说,C# 类型的关键字及其别名可以互换。下面的两行代码完全等价。

int a = 0;
Int32 b=0;

 


猜你喜欢
java基础 4173 (class)接口(interface)组byte: byte是8位、有符号,以二进制补码表示; 最小值是-128(-2^7); 最大值是127(2^7-1); 默认值是0; byt
weblog 1001 mysql整范围MySQL支持多种,大致可以分为三值、日期/时间和字符串(字符)。其,整包括:TINYINT、SMALLINT、MEDIUMINT、INT和
weblog 5175 栗子usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceConsoleApplication3{classProgram{staticvoidMain(string[]args){Stones=newStone(1000)
weblog 1018 mysql库日期date值int转换一、date换intSELECTUNIX_TIMESTAMP(now())二、int转dateSELECTFROM_UNIXTIME(1578636398)上述都精确到秒值
算法基础 1862 如果一个实现了一个接口,如何获取接口实际importjava.lang.reflect.ParameterizedType; importjava.lang.reflect.Type
weblog 2261 一个案例说明#includeiostreamusingnamespacestd;/**定义函指针*///typedef声明为一个指针函MethodPointer//int为指针指向函返回
weblog 1839 usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;namespaceConsoleApplication3{classProgram{staticvoidMain(string[]args){//Action委托Actiona=newAc
java基础 4904 javabyte相加超出范围变负解析例: @Test publicvoidt(){ byteb=127; b+=127; System.out.println(b); }最终运行得出
目录
没有一个冬天不可逾越,没有一个春天不会来临。最慢的步伐不是跬步,而是徘徊,最快的脚步不是冲刺,而是坚持。