内置类型(C# 参考)Built-in types (C# reference)

下表列出了 C# 内置类型:The following table lists the C# built-in value types:

C# 类型关键字C# type keyword .NET 类型.NET type
bool System.Boolean
byte System.Byte
sbyte System.SByte
char System.Char
decimal System.Decimal
double System.Double
float System.Single
int System.Int32
uint System.UInt32
long System.Int64
ulong System.UInt64
short System.Int16
ushort System.UInt16

下表列出了 C# 内置引用类型:The following table lists the C# built-in reference types:

C# 类型关键字C# type keyword .NET 类型.NET type
object System.Object
string System.String

在上表中,左侧列中的每个 C# 类型关键字都是相应 .NET 类型的别名。In the preceding tables, each C# type keyword from the left column is an alias for the corresponding .NET type. 它们是可互换的。They are interchangeable. 例如,以下声明声明了相同类型的变量:For example, the following declarations declare variables of the same type:

int a = 123;
System.Int32 b = 123;

void 关键字表示缺少类型。The void keyword represents the absence of a type. 将其用作不返回值的方法的返回类型。You use it as the return type of a method that doesn't return a value.

请参阅See also