標籤:結構 nullable bsp int 記憶體回收 system.in char alt 類型
實值型別與參考型別
實值型別(Value Type),實值型別執行個體通常分配線上程的堆棧(stack)上,並且不包含任何指向執行個體資料的指標,因為變數本身就包含了其執行個體資料
C#的所有實值型別均隱式派生自System.ValueType:
結構體:struct(直接派生於System.ValueType),使用者定義的結構體(派生於System.ValueType);
整 型:sbyte(System.SByte的別名),short(System.Int16),int(System.Int32),long (System.Int64),byte(System.Byte),ushort(System.UInt16),uint (System.UInt32),ulong(System.UInt64),char(System.Char);
浮點型:float(System.Single),double(System.Double); 用於財務計算的高精度decimal型:decimal(System.Decimal)。
bool型:bool(System.Boolean的別名);
枚舉:enum(派生於System.Enum);
可空類型、派生於System.Nullable<T>泛型結構體,T?實際上是System.Nullable<T>的別名。
參考型別
C#有以下一些參考型別:
數組(派生於System.Array)
類:class(派生於System.Object);
介面:interface;
委託:delegate(派生於System.Delegate)。
object(System.Object);
字串:string(System.String)。
記憶體配置圖(stack、Heap):
託管堆是基於進程的。
GC
深入解密.NET(GC記憶體回收)