內建類型(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 |
dynamic |
System.Object |
在上表中,左欄中的每個 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.