出處 https://msdn.microsoft.com/zh-tw/library/ya5y69ds.aspx

 

下表顯示內建 C# 型別的關鍵字,這些是 System 命名空間裡預先定義型別的別名。

C# 型別

.NET Framework 型別

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

object

System.Object

short

System.Int16

ushort

System.UInt16

string

System.String

 

註解
 

表中除了 object 和 string 以外的所有型別,都視為簡單型別。

C# 型別關鍵字和它們的別名可互換。 例如,您可以使用下列任一個宣告來宣告整數變數:

 
 
int x = 123;
System.Int32 x = 123;

若要顯示任一 C# 型別的實際型別,請使用系統方法 GetType() 例如,下列陳述式顯示了代表 myVariable 型別的系統別名:

 
 
Console.WriteLine(myVariable.GetType());

您也可以使用 typeof 運算子。

arrow
arrow
    文章標籤
    built-in C# types
    全站熱搜

    痞客興 發表在 痞客邦 留言(0) 人氣()