| C# 關鍵字 | FCL 類型 | CLS-Compliant |
|---|---|---|
| sbyte | System.SByte | No |
| byte | System.Byte | Yes |
| short | System.Int16 | Yes |
| ushort | System.UInt16 | No |
| int | System.Int32 | Yes |
| uint | System.UInt32 | No |
| long | System.Int64 | Yes |
| ulong | System.UInt64 | No |
| char | System.Char | Yes |
| float | System.Single | Yes |
| double | System.Double | Yes |
| decimal | System.Decimal | Yes |
| object | System.Object | Yes |
| string | System.String | Yes |
int 編譯後即為 System.Int32,四種宣告方式(int a=0; Int32 b=0; int c=new int(); System.Int32 d=new System.Int32();)產生完全相同的 IL。string 是 System.String 的編譯器別名,無實質差異。
using sbyte = System.SByte;
using int = System.Int32;
using string = System.String;
Int32 i = 0;
Int64 j = i; // 隱含轉換
// IL: ldloc.0 → conv.i8 → stloc.1
雖 Int32、Int64 無繼承關係,但基元類型層級定義了安全的隱含/顯式轉換規則,編譯器插入 conv.i8 完成擴展轉換。