參考型別 (C# 參考)Reference types (C# Reference)

C# 中有兩種型別:參考型別和實值型別。There are two kinds of types in C#: reference types and value types. 參考型別的變數會儲存對其資料 (物件) 的參考,而實值型別的變數則會直接包含其資料。Variables of reference types store references to their data (objects), while variables of value types directly contain their data. 使用參考型別時,這兩個變數可以參考相同的物件,因此對其中一個變數進行的作業可能會影響另一個變數所參考的物件。With reference types, two variables can reference the same object; therefore, operations on one variable can affect the object referenced by the other variable. 使用實值型別時,每個變數都有自己的資料複本,因此對某一個變數進行的作業,不可能會影響另一個變數 (但 in、ref 及 out 參數變數除外),請參閱 inrefout 參數修飾詞)。With value types, each variable has its own copy of the data, and it is not possible for operations on one variable to affect the other (except in the case of in, ref and out parameter variables; see in, ref and out parameter modifier).

下列關鍵字用來宣告參考型別:The following keywords are used to declare reference types:

C# 還提供下列內建參考型別:C# also provides the following built-in reference types:

另請參閱See also