本文為機器翻譯文章。如需檢視英文版,請選取 [原文] 核取方塊。您也可以將滑鼠指標移到文字上,即可在快顯視窗顯示英文原文。
譯文
原文

String 類別

 

以一連串的 UTF-16 字碼單位表示文字。

若要瀏覽此類型的 .NET Framework 原始程式碼,請參閱參考來源

命名空間:   System
組件:  mscorlib (於 mscorlib.dll)

System.Object
  System.String

[<Sealed>]
[<SerializableAttribute>]
[<ComVisibleAttribute(true)>]
type String = 
    class
        interface IComparable
        interface ICloneable
        interface IConvertible
        interface IEnumerable
        interface IComparable<string>
        interface IEnumerable<char>
        interface IEquatable<string>
    end

名稱描述
System_CAPS_pubmethodString(Char*)

String 類別的新執行個體初始化為 Unicode 字元陣列的指定指標所指示的值。

System_CAPS_pubmethodString(Char*, Int32, Int32)

String 類別的新執行個體初始化為 Unicode 字元陣列、在陣列內起始字元的位置以及長度等等的指定指標所指示的值。

System_CAPS_pubmethodString(Char, Int32)

String 類別的新執行個體初始化為由重複指定次數的指定 Unicode 字元所指示的值。

System_CAPS_pubmethodString(Char[])

String 類別的新執行個體初始化為 Unicode 字元陣列所指示的值。

System_CAPS_pubmethodString(Char[], Int32, Int32)

String 類別的新執行個體初始化為 Unicode 字元陣列、在陣列內起始字元的位置和長度等等所指示的值。

System_CAPS_pubmethodString(SByte*)

String 類別的新執行個體初始化為 8 位元帶正負號整數 (Signed Integer) 陣列的指標所指示的值。

System_CAPS_pubmethodString(SByte*, Int32, Int32)

String 類別的新執行個體初始化為 8 位元帶正負號整數的陣列、在該陣列內開始位置和長度的指定指標所指示的值。

System_CAPS_pubmethodString(SByte*, Int32, Int32, Encoding)

String 類別的新執行個體初始化為 8 位元帶正負號整數的陣列、在該陣列內開始位置、長度和 Encoding 物件的指定指標所指示的值。

名稱描述
System_CAPS_pubpropertyChars(Int32)

取得目前 Char 物件中指定位置的 String 物件。

System_CAPS_pubpropertyLength

取得目前 String 物件中字元的數目。

名稱描述
System_CAPS_pubmethodClone()

傳回對 String 這個執行個體的參考。

System_CAPS_pubmethodSystem_CAPS_staticCompare(String, Int32, String, Int32, Int32)

比較兩個指定的 String 物件子字串,並傳回一個整數,指出它們在排序順序中的相對位置。

System_CAPS_pubmethodSystem_CAPS_staticCompare(String, Int32, String, Int32, Int32, Boolean)

比較兩個指定之 String 物件的子字串,忽略或區分兩者的大小寫,並傳回一個整數,表示兩者在排序順序中的相對位置。

System_CAPS_pubmethodSystem_CAPS_staticCompare(String, Int32, String, Int32, Int32, Boolean, CultureInfo)

比較兩個指定之 String 物件的子字串,忽略或區分兩者的大小寫,並使用文化特性資訊來影響比較,然後傳回一個整數,表示兩者在排序順序中的相對位置。

System_CAPS_pubmethodSystem_CAPS_staticCompare(String, Int32, String, Int32, Int32, CultureInfo, CompareOptions)

比較兩個指定的 String 物件的子字串,使用指定的比較選項及特定文化特性資訊影響比較,然後傳回整數,這個整數表示這兩個子字串在排序次序中彼此的關聯性。

System_CAPS_pubmethodSystem_CAPS_staticCompare(String, Int32, String, Int32, Int32, StringComparison)

使用指定的規則比較兩個指定之 String 物件的子字串,並傳回一個整數,表示兩者在排序順序中的相對位置。

System_CAPS_pubmethodSystem_CAPS_staticCompare(String, String)

比較兩個指定的 String 物件,並傳回一個整數,指出它們在排序順序中的相對位置。

System_CAPS_pubmethodSystem_CAPS_staticCompare(String, String, Boolean)

比較兩個指定的 String 物件,忽略或區分兩者的大小寫,並傳回一個整數,表示兩者在排序順序中的相對位置。

System_CAPS_pubmethodSystem_CAPS_staticCompare(String, String, Boolean, CultureInfo)

比較兩個指定的 String 物件,忽略或區分兩者的大小寫,並使用特定文化特性資訊來影響比較,然後傳回一個整數,表示兩者在排序順序中的相對位置。

System_CAPS_pubmethodSystem_CAPS_staticCompare(String, String, CultureInfo, CompareOptions)

比較兩個指定的 String 物件,使用指定的比較選項及特定文化特性資訊影響比較,然後傳回整數,這個整數表示這兩個字串在排序次序中彼此的關聯性。

System_CAPS_pubmethodSystem_CAPS_staticCompare(String, String, StringComparison)

使用指定的規則比較兩個指定的 String 物件,並傳回一個整數,表示兩者在排序順序中的相對位置。

System_CAPS_pubmethodSystem_CAPS_staticCompareOrdinal(String, Int32, String, Int32, Int32)

藉由評估每個子字串中對應的 String 物件之數字值,比較兩個指定的 Char 物件之子字串。

System_CAPS_pubmethodSystem_CAPS_staticCompareOrdinal(String, String)

藉由評估每個字串中對應的 String 物件之數字值,比較兩個指定 Char 物件。

System_CAPS_pubmethodCompareTo(Object)

比較這個執行個體與指定的 Object,並且指出這個執行個體在排序次序中,位於所指定 Object 之前、之後或相同位置。

System_CAPS_pubmethodCompareTo(String)

比較這個執行個體與指定的 String 物件,並且表示這個執行個體在排序次序中,位於所指定字串之前、之後或相同位置。

System_CAPS_pubmethodSystem_CAPS_staticConcat(IEnumerable<String>)

串連類型 IEnumerable<'T> 之已建構的 String 集合的成員。

System_CAPS_pubmethodSystem_CAPS_staticConcat(Object)

建立指定之物件的字串表示。

System_CAPS_pubmethodSystem_CAPS_staticConcat(Object, Object)

串連兩個指定之物件的字串表示。

System_CAPS_pubmethodSystem_CAPS_staticConcat(Object, Object, Object)

串連三個指定之物件的字串表示。

System_CAPS_pubmethodSystem_CAPS_staticConcat(Object, Object, Object, Object)

串連四個指定的物件之字串表示和選擇性變數長度參數清單中所指定的任何物件。

System_CAPS_pubmethodSystem_CAPS_staticConcat(Object[])

串連指定之 Object 陣列中項目的字串表示法。

System_CAPS_pubmethodSystem_CAPS_staticConcat(String, String)

串連 String 的兩個指定執行個體。

System_CAPS_pubmethodSystem_CAPS_staticConcat(String, String, String)

串連 String 的三個指定執行個體。

System_CAPS_pubmethodSystem_CAPS_staticConcat(String, String, String, String)

串連 String 的四個指定執行個體。

System_CAPS_pubmethodSystem_CAPS_staticConcat(String[])

串連指定 String 陣列中的項目。

System_CAPS_pubmethodSystem_CAPS_staticConcat<'T>(IEnumerable<'T>)

串連 IEnumerable<'T> 實作的成員。

System_CAPS_pubmethodContains(String)

傳回值,這個值表示指定的子字串是否會出現在這個字串內。

System_CAPS_pubmethodSystem_CAPS_staticCopy(String)

使用與指定的 String 相同的值,建立 String 的新執行個體。

System_CAPS_pubmethodCopyTo(Int32, Char[], Int32, Int32)

將字元的指定數目從這個執行個體的指定位置,複製到 Unicode 字元陣列的指定位置。

System_CAPS_pubmethodEndsWith(String)

判斷這個字串執行個體的結尾是否符合指定的字串。

System_CAPS_pubmethodEndsWith(String, Boolean, CultureInfo)

判斷當使用指定之文化特性進行比較時,這個字串執行個體的結尾是否符合指定的字串。

System_CAPS_pubmethodEndsWith(String, StringComparison)

判斷當使用指定的比較選項進行比較時,這個字串執行個體的結尾是否符合指定的字串。

System_CAPS_pubmethodEquals(Object)

判斷這個執行個體和指定的物件 (同時還必須是 String 物件) 是否具有相同的值。(覆寫 Object.Equals(Object)。)

System_CAPS_pubmethodEquals(String)

判斷這個執行個體和另一個指定的 String 物件是否具有相同的值。

System_CAPS_pubmethodSystem_CAPS_staticEquals(String, String)

判斷兩個指定的 String 物件是否具有相同的值。

System_CAPS_pubmethodSystem_CAPS_staticEquals(String, String, StringComparison)

判斷兩個指定的 String 物件是否具有相同的值。 參數可指定用於比較的文化特性、大小寫及排序規則。

System_CAPS_pubmethodEquals(String, StringComparison)

判斷這個字串和指定的 String 物件是否具有相同的值。 參數可指定用於比較的文化特性、大小寫及排序規則。

System_CAPS_pubmethodSystem_CAPS_staticFormat(IFormatProvider, String, Object)

以對應物件的字串表示,取代指定之字串中的一或多個格式項目。 參數提供特定文化特性格式資訊。

System_CAPS_pubmethodSystem_CAPS_staticFormat(IFormatProvider, String, Object, Object)

以兩個指定之物件的字串表示,取代指定之字串中的格式項目。 參數提供特定文化特性格式資訊。

System_CAPS_pubmethodSystem_CAPS_staticFormat(IFormatProvider, String, Object, Object, Object)

以三個指定之物件的字串表示,取代指定之字串中的格式項目。 參數提供特定文化特性格式資訊。

System_CAPS_pubmethodSystem_CAPS_staticFormat(IFormatProvider, String, Object[])

以指定陣列中對應物件的字串表示,取代指定之字串中的格式項目。 參數提供特定文化特性格式資訊。

System_CAPS_pubmethodSystem_CAPS_staticFormat(String, Object)

以指定之物件的字串表示,取代指定之字串中的一或多個格式項目。

System_CAPS_pubmethodSystem_CAPS_staticFormat(String, Object, Object)

以兩個指定之物件的字串表示,取代指定之字串中的格式項目。

System_CAPS_pubmethodSystem_CAPS_staticFormat(String, Object, Object, Object)

以三個指定之物件的字串表示,取代指定之字串中的格式項目。

System_CAPS_pubmethodSystem_CAPS_staticFormat(String, Object[])

以指定陣列中對應物件的字串表示,取代指定之字串中的格式項目。

System_CAPS_pubmethodGetEnumerator()

擷取可以逐一查看這個字串中個別字元的物件。

System_CAPS_pubmethodGetHashCode()

傳回這個字串的雜湊碼。(覆寫 Object.GetHashCode()。)

System_CAPS_pubmethodGetType()

取得目前執行個體的 Type(繼承自 Object。)

System_CAPS_pubmethodGetTypeCode()

傳回類別 TypeCodeString

System_CAPS_pubmethodIndexOf(Char)

報告這個字串中指定之 Unicode 字元第一次出現時的所在索引 (以零為起始)。

System_CAPS_pubmethodIndexOf(Char, Int32)

報告這個字串中指定之 Unicode 字元第一次出現時的所在索引 (以零為起始)。 搜尋從指定的字元位置開始。

System_CAPS_pubmethodIndexOf(Char, Int32, Int32)

報告這個執行個體中指定之字元第一次出現時的所在索引 (以零為起始)。 搜尋從指定的字元位置開始,並檢視指定數目的字元位置。

System_CAPS_pubmethodIndexOf(String)

回報這個執行個體中指定之字串第一次出現時的所在索引 (以零為起始)。

System_CAPS_pubmethodIndexOf(String, Int32)

回報這個執行個體中指定之字串第一次出現時的所在索引 (以零為起始)。 搜尋從指定的字元位置開始。

System_CAPS_pubmethodIndexOf(String, Int32, Int32)

回報這個執行個體中指定之字串第一次出現時的所在索引 (以零為起始)。 搜尋從指定的字元位置開始,並檢視指定數目的字元位置。

System_CAPS_pubmethodIndexOf(String, Int32, Int32, StringComparison)

報告目前 String 物件中指定之字串第一次出現時的所在索引 (以零為起始)。 參數會指定目前字串中的開始搜尋位置、目前字串中要搜尋的字元數目,以及要用於指定字串的搜尋類型。

System_CAPS_pubmethodIndexOf(String, Int32, StringComparison)

報告目前 String 物件中指定之字串第一次出現時的所在索引 (以零為起始)。 參數會指定目前字串中的開始搜尋位置和要用於指定字串的搜尋類型。

System_CAPS_pubmethodIndexOf(String, StringComparison)

報告目前 String 物件中指定之字串第一次出現時的所在索引 (以零為起始)。 參數會指定要用於指定字串的搜尋類型。

System_CAPS_pubmethodIndexOfAny(Char[])

報告指定的 Unicode 字元陣列中,任何字元在這個執行個體中第一次出現時的所在索引 (以零為起始)。

System_CAPS_pubmethodIndexOfAny(Char[], Int32)

報告指定的 Unicode 字元陣列中,任何字元在這個執行個體中第一次出現時的所在索引 (以零為起始)。 搜尋從指定的字元位置開始。

System_CAPS_pubmethodIndexOfAny(Char[], Int32, Int32)

報告指定的 Unicode 字元陣列中,任何字元在這個執行個體中第一次出現時的所在索引 (以零為起始)。 搜尋從指定的字元位置開始,並檢視指定數目的字元位置。

System_CAPS_pubmethodInsert(Int32, String)

傳回新字串,其中已在這個執行個體中指定的索引位置插入指定的字串。

System_CAPS_pubmethodSystem_CAPS_staticIntern(String)

擷取指定的 String 的系統參考。

System_CAPS_pubmethodSystem_CAPS_staticIsInterned(String)

擷取對指定 String 的參考。

System_CAPS_pubmethodIsNormalized()

指出這個字串是否為 Unicode 正規化格式 C。

System_CAPS_pubmethodIsNormalized(NormalizationForm)

指出這個字串是否為指定的 Unicode 正規化格式。

System_CAPS_pubmethodSystem_CAPS_staticIsNullOrEmpty(String)

表示指定的字串是否為 nullEmpty 字串。

System_CAPS_pubmethodSystem_CAPS_staticIsNullOrWhiteSpace(String)

表示指定的字串是否為 null、空白,或只由空白字元組成的字串。

System_CAPS_pubmethodSystem_CAPS_staticJoin(String, IEnumerable<String>)

串連類型 IEnumerable<'T> 之已建構的 String 集合的成員,並在每個成員之間使用指定的分隔符號。

System_CAPS_pubmethodSystem_CAPS_staticJoin(String, Object[])

串連物件陣列的項目,並在每個項目之間使用指定的分隔符號。

System_CAPS_pubmethodSystem_CAPS_staticJoin(String, String[])

串連字串陣列的所有項目,並在每個項目之間使用指定的分隔符號。

System_CAPS_pubmethodSystem_CAPS_staticJoin(String, String[], Int32, Int32)

串連字串陣列的指定項目,並在每個項目之間使用指定的分隔符號。

System_CAPS_pubmethodSystem_CAPS_staticJoin<'T>(String, IEnumerable<'T>)

串連集合的成員,並在每個成員之間使用指定的分隔符號。

System_CAPS_pubmethodLastIndexOf(Char)

報告這個執行個體中指定之 Unicode 字元最後一次出現時的所在索引 (以零為起始)。

System_CAPS_pubmethodLastIndexOf(Char, Int32)

報告這個執行個體中指定之 Unicode 字元最後一次出現時的所在索引 (以零為起始)。 搜尋會從指定的字元位置開始,然後反向朝字串的開頭進行。

System_CAPS_pubmethodLastIndexOf(Char, Int32, Int32)

報告這個執行個體的子字串中,指定的 Unicode 字元最後一次出現時的所在索引 (以零為起始)。 搜尋會從指定的字元位置開始,然後反向朝字串開頭指定數目的字元位置進行。

System_CAPS_pubmethodLastIndexOf(String)

回報這個執行個體中指定之字串最後一次出現時的所在索引 (以零為起始)。

System_CAPS_pubmethodLastIndexOf(String, Int32)

回報這個執行個體中指定之字串最後一次出現時的所在索引 (以零為起始)。 搜尋會從指定的字元位置開始,然後反向朝字串的開頭進行。

System_CAPS_pubmethodLastIndexOf(String, Int32, Int32)

回報這個執行個體中指定之字串最後一次出現時的所在索引 (以零為起始)。 搜尋會從指定的字元位置開始,然後反向朝字串開頭指定數目的字元位置進行。

System_CAPS_pubmethodLastIndexOf(String, Int32, Int32, StringComparison)

回報這個執行個體中指定之字串最後一次出現時的所在索引 (以零為起始)。 搜尋會從指定的字元位置開始,然後反向朝字串開頭指定數目的字元位置進行。 參數會指定搜尋指定字串時要執行的比較類型。

System_CAPS_pubmethodLastIndexOf(String, Int32, StringComparison)

報告目前 String 物件中指定之字串最後一次出現時的所在索引 (以零為起始)。 搜尋會從指定的字元位置開始,然後反向朝字串的開頭進行。 參數會指定搜尋指定字串時要執行的比較類型。

System_CAPS_pubmethodLastIndexOf(String, StringComparison)

報告目前 String 物件中指定之字串最後一次出現時的所在索引 (以零為起始)。 參數會指定要用於指定字串的搜尋類型。

System_CAPS_pubmethodLastIndexOfAny(Char[])

報告 Unicode 陣列中的一或多個指定的字元,在這個執行個體中最後一次出現時的所在索引 (以零為起始)。

System_CAPS_pubmethodLastIndexOfAny(Char[], Int32)

報告 Unicode 陣列中的一或多個指定的字元,在這個執行個體中最後一次出現時的所在索引 (以零為起始)。 搜尋會從指定的字元位置開始,然後反向朝字串的開頭進行。

System_CAPS_pubmethodLastIndexOfAny(Char[], Int32, Int32)

報告 Unicode 陣列中的一或多個指定的字元,在這個執行個體中最後一次出現時的所在索引 (以零為起始)。 搜尋會從指定的字元位置開始,然後反向朝字串開頭指定數目的字元位置進行。

System_CAPS_pubmethodNormalize()

傳回新的字串,其文字值與這個字串相同,但是其二進位表示為 Unicode 正規化格式 C。

System_CAPS_pubmethodNormalize(NormalizationForm)

傳回新的字串,其文字值與這個字串相同,但是其二進位表示為特定的 Unicode 正規化格式。

System_CAPS_pubmethodPadLeft(Int32)

傳回新字串,此字串會以空格填補左側至指定的總長度,靠右對齊這個執行個體中的字元。

System_CAPS_pubmethodPadLeft(Int32, Char)

傳回新字串,此字串會以指定的 Unicode 字元填補左側至指定的總長度,靠右對齊這個執行個體中的字元。

System_CAPS_pubmethodPadRight(Int32)

傳回新字串,此字串會以空格填補右側至指定的總長度,靠左對齊這個字串中的字元。

System_CAPS_pubmethodPadRight(Int32, Char)

傳回新字串,此字串會以指定的 Unicode 字元填補右側至指定的總長度,靠左對齊這個字串中的字元。

System_CAPS_pubmethodRemove(Int32)

傳回新字串,其中已刪除目前執行個體中的所有字元 (從指定位置開始到最後一個位置為止)。

System_CAPS_pubmethodRemove(Int32, Int32)

傳回新字串,其中已刪除在目前執行個體中指定位置開始之指定數目的字元。

System_CAPS_pubmethodReplace(Char, Char)

傳回新字串,其中這個執行個體中所有出現的指定 Unicode 字元都取代成其他指定的 Unicode 字元。

System_CAPS_pubmethodReplace(String, String)

傳回新字串,其中目前執行個體中所有出現的指定字串,都取代成其他指定的字串。

System_CAPS_pubmethodSplit(Char[])

根據陣列中的字元分割字串成子字串。

System_CAPS_pubmethodSplit(Char[], Int32)

根據陣列中的字元分割字串成最大數目的子字串。 您也要指定傳回的子字串之最大數目。

System_CAPS_pubmethodSplit(Char[], Int32, StringSplitOptions)

根據陣列中的字元分割字串成最大數目的子字串。

System_CAPS_pubmethodSplit(Char[], StringSplitOptions)

根據陣列中的字元分割字串成子字串。 您可以指定子字串是否包含空的陣列元素。

System_CAPS_pubmethodSplit(String[], Int32, StringSplitOptions)

根據陣列中的字串分割字串成最大數目的子字串。 您可以指定子字串是否包含空的陣列元素。

System_CAPS_pubmethodSplit(String[], StringSplitOptions)

根據陣列中的字串分割字串成子字串。 您可以指定子字串是否包含空的陣列元素。

System_CAPS_pubmethodStartsWith(String)

判斷這個字串執行個體的開頭是否符合指定的字串。

System_CAPS_pubmethodStartsWith(String, Boolean, CultureInfo)

判斷當使用指定之文化特性進行比較時,這個字串執行個體的開頭是否符合指定的字串。

System_CAPS_pubmethodStartsWith(String, StringComparison)

判斷當使用指定之比較選項進行比較時,這個字串執行個體的開頭是否符合指定的字串。

System_CAPS_pubmethodSubstring(Int32)

從這個執行個體擷取子字串。 子字串會在指定的字元位置開始並繼續到字串的結尾。

System_CAPS_pubmethodSubstring(Int32, Int32)

從這個執行個體擷取子字串。 子字串起始於指定的字元位置,並且具有指定的長度。

System_CAPS_pubmethodToCharArray()

將這個執行個體中的字元複製到 Unicode 字元陣列中。

System_CAPS_pubmethodToCharArray(Int32, Int32)

將這個執行個體的指定子字串字元複製到 Unicode 字元陣列。

System_CAPS_pubmethodToLower()

傳回此字串轉換為小寫的版本。

System_CAPS_pubmethodToLower(CultureInfo)

使用指定之文化特性的大小寫規則,傳回這個字串轉換成小寫的複本。

System_CAPS_pubmethodToLowerInvariant()

使用不因文化特性而異的大小寫規則,傳回轉換成小寫的這個 String 物件之複本。

System_CAPS_pubmethodToString()

傳回這個 String 執行個體;不會實際執行轉換。(覆寫 Object.ToString()。)

System_CAPS_pubmethodToString(IFormatProvider)

傳回這個 String 執行個體;不會實際執行轉換。

System_CAPS_pubmethodToUpper()

傳回此字串轉換為大寫的版本。

System_CAPS_pubmethodToUpper(CultureInfo)

使用指定之文化特性的大小寫規則,傳回這個字串轉換成大寫的複本。

System_CAPS_pubmethodToUpperInvariant()

使用不因文化特性而異的大小寫規則,傳回轉換成大寫的這個 String 物件之複本。

System_CAPS_pubmethodTrim()

從目前的 String 物件中移除所有的開頭和結尾空白字元。

System_CAPS_pubmethodTrim(Char[])

從目前的 String 物件中移除陣列中指定之一組字元的所有開頭和結尾指定項目。

System_CAPS_pubmethodTrimEnd(Char[])

從目前的 String 物件中移除陣列中指定之一組字元的所有結尾指定項目。

System_CAPS_pubmethodTrimStart(Char[])

從目前的 String 物件中移除陣列中指定之一組字元的所有開頭指定項目。

名稱描述
System_CAPS_pubfieldSystem_CAPS_staticEmpty

表示空字串。 此欄位為唯讀。

名稱描述
System_CAPS_puboperatorSystem_CAPS_staticEquality(String, String)

判斷兩個指定的字串是否具有相同的值。

System_CAPS_puboperatorSystem_CAPS_staticInequality(String, String)

判斷兩個指定的字串是否具有不同的值。

名稱描述
System_CAPS_pubinterfaceSystem_CAPS_privmethodIEnumerable<Char>.GetEnumerator()

傳回列舉值,可逐一查看目前的 String 物件。

System_CAPS_pubinterfaceSystem_CAPS_privmethodIEnumerable.GetEnumerator()

傳回列舉值,可逐一查看目前的 String 物件。

System_CAPS_pubinterfaceSystem_CAPS_privmethodIConvertible.ToBoolean(IFormatProvider)

此 API 支援 產品 基礎結構,而且不適合直接從程式碼使用。 如需這個成員的說明,請參閱 ToBoolean

System_CAPS_pubinterfaceSystem_CAPS_privmethodIConvertible.ToByte(IFormatProvider)

此 API 支援 產品 基礎結構,而且不適合直接從程式碼使用。 如需這個成員的說明,請參閱 ToByte

System_CAPS_pubinterfaceSystem_CAPS_privmethodIConvertible.ToChar(IFormatProvider)

此 API 支援 產品 基礎結構,而且不適合直接從程式碼使用。 如需這個成員的說明,請參閱 ToChar

System_CAPS_pubinterfaceSystem_CAPS_privmethodIConvertible.ToDateTime(IFormatProvider)

此 API 支援 產品 基礎結構,而且不適合直接從程式碼使用。 如需這個成員的說明,請參閱 ToDateTime

System_CAPS_pubinterfaceSystem_CAPS_privmethodIConvertible.ToDecimal(IFormatProvider)

此 API 支援 產品 基礎結構,而且不適合直接從程式碼使用。 如需這個成員的說明,請參閱 ToDecimal

System_CAPS_pubinterfaceSystem_CAPS_privmethodIConvertible.ToDouble(IFormatProvider)

此 API 支援 產品 基礎結構,而且不適合直接從程式碼使用。 如需這個成員的說明,請參閱 ToDouble

System_CAPS_pubinterfaceSystem_CAPS_privmethodIConvertible.ToInt16(IFormatProvider)

此 API 支援 產品 基礎結構,而且不適合直接從程式碼使用。 如需這個成員的說明,請參閱 ToInt16

System_CAPS_pubinterfaceSystem_CAPS_privmethodIConvertible.ToInt32(IFormatProvider)

此 API 支援 產品 基礎結構,而且不適合直接從程式碼使用。 如需這個成員的說明,請參閱 ToInt32

System_CAPS_pubinterfaceSystem_CAPS_privmethodIConvertible.ToInt64(IFormatProvider)

此 API 支援 產品 基礎結構,而且不適合直接從程式碼使用。 如需這個成員的說明,請參閱 ToInt64

System_CAPS_pubinterfaceSystem_CAPS_privmethodIConvertible.ToSByte(IFormatProvider)

此 API 支援 產品 基礎結構,而且不適合直接從程式碼使用。 如需這個成員的說明,請參閱 ToSByte

System_CAPS_pubinterfaceSystem_CAPS_privmethodIConvertible.ToSingle(IFormatProvider)

此 API 支援 產品 基礎結構,而且不適合直接從程式碼使用。 如需這個成員的說明,請參閱 ToSingle

System_CAPS_pubinterfaceSystem_CAPS_privmethodIConvertible.ToType(Type, IFormatProvider)

此 API 支援 產品 基礎結構,而且不適合直接從程式碼使用。 如需這個成員的說明,請參閱 ToType

System_CAPS_pubinterfaceSystem_CAPS_privmethodIConvertible.ToUInt16(IFormatProvider)

此 API 支援 產品 基礎結構,而且不適合直接從程式碼使用。 如需這個成員的說明,請參閱 ToUInt16

System_CAPS_pubinterfaceSystem_CAPS_privmethodIConvertible.ToUInt32(IFormatProvider)

此 API 支援 產品 基礎結構,而且不適合直接從程式碼使用。 如需這個成員的說明,請參閱 ToUInt32

System_CAPS_pubinterfaceSystem_CAPS_privmethodIConvertible.ToUInt64(IFormatProvider)

此 API 支援 產品 基礎結構,而且不適合直接從程式碼使用。 如需這個成員的說明,請參閱 ToUInt64

名稱描述
System_CAPS_pubmethodAggregate<Char>(Func<Char, Char, Char>)

多載。將累加函式套用到序列。(由 Enumerable 定義。)

System_CAPS_pubmethodAggregate<Char, 'TAccumulate>('TAccumulate, Func<'TAccumulate, Char, 'TAccumulate>)

多載。將累加函式套用到序列。 使用指定的初始值做為初始累加值。(由 Enumerable 定義。)

System_CAPS_pubmethodAggregate<Char, 'TAccumulate, 'TResult>('TAccumulate, Func<'TAccumulate, Char, 'TAccumulate>, Func<'TAccumulate, 'TResult>)

多載。將累加函式套用到序列。 使用指定的值做為初始累加值,並使用指定的函式來選取結果值。(由 Enumerable 定義。)

System_CAPS_pubmethodAll<Char>(Func<Char, Boolean>)

判斷序列中的所有項目是否全都符合條件。(由 Enumerable 定義。)

System_CAPS_pubmethodAny<Char>()

多載。判斷序列是否包含任何項目。(由 Enumerable 定義。)

System_CAPS_pubmethodAny<Char>(Func<Char, Boolean>)

多載。判斷序列中的任何項目是否符合條件。(由 Enumerable 定義。)

System_CAPS_pubmethodAsEnumerable<Char>()

傳回輸入型別為 IEnumerable<'T>(由 Enumerable 定義。)

System_CAPS_pubmethodAsParallel()

多載。啟用查詢的平行化作業。(由 ParallelEnumerable 定義。)

System_CAPS_pubmethodAsParallel<Char>()

多載。啟用查詢的平行化作業。(由 ParallelEnumerable 定義。)

System_CAPS_pubmethodAsQueryable()

多載。將轉換 IEnumerableIQueryable(由 Queryable 定義。)

System_CAPS_pubmethodAsQueryable<Char>()

多載。將轉換為泛型 IEnumerable<'T> 至泛型 IQueryable<'T>(由 Queryable 定義。)

System_CAPS_pubmethodAverage<Char>(Func<Char, Decimal>)

多載。計算序列的平均值 Decimal 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodAverage<Char>(Func<Char, Double>)

多載。計算序列的平均值 Double 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodAverage<Char>(Func<Char, Int32>)

多載。計算序列的平均值 Int32 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodAverage<Char>(Func<Char, Int64>)

多載。計算序列的平均值 Int64 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodAverage<Char>(Func<Char, Nullable<Decimal>>)

多載。計算可為 null 的序列的平均值 Decimal 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodAverage<Char>(Func<Char, Nullable<Double>>)

多載。計算可為 null 的序列的平均值 Double 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodAverage<Char>(Func<Char, Nullable<Int32>>)

多載。計算可為 null 的序列的平均值 Int32 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodAverage<Char>(Func<Char, Nullable<Int64>>)

多載。計算可為 null 的序列的平均值 Int64 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodAverage<Char>(Func<Char, Nullable<Single>>)

多載。計算可為 null 的序列的平均值 Single 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodAverage<Char>(Func<Char, Single>)

多載。計算序列的平均值 Single 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodCast<'TResult>()

將轉換的項目 IEnumerable 指定的型別。(由 Enumerable 定義。)

System_CAPS_pubmethodConcat<Char>(IEnumerable<Char>)

串連兩個序列。(由 Enumerable 定義。)

System_CAPS_pubmethodContains<Char>(Char)

多載。判斷序列是否包含指定的項目,使用預設相等比較子。(由 Enumerable 定義。)

System_CAPS_pubmethodContains<Char>(Char, IEqualityComparer<Char>)

多載。判斷序列是否包含指定的項目,使用指定的 IEqualityComparer<'T>(由 Enumerable 定義。)

System_CAPS_pubmethodCount<Char>()

多載。傳回序列中的項目數目。(由 Enumerable 定義。)

System_CAPS_pubmethodCount<Char>(Func<Char, Boolean>)

多載。傳回表示指定之序列中的項目數目符合條件的數字。(由 Enumerable 定義。)

System_CAPS_pubmethodDefaultIfEmpty<Char>()

多載。傳回單一集合中指定的序列或型別參數的預設值的項目,如果序列是空的。(由 Enumerable 定義。)

System_CAPS_pubmethodDefaultIfEmpty<Char>(Char)

多載。傳回單一集合中指定的序列或指定的值的項目,如果序列是空的。(由 Enumerable 定義。)

System_CAPS_pubmethodDistinct<Char>()

多載。使用預設相等比較子來比較值,從序列傳回不同的項目。(由 Enumerable 定義。)

System_CAPS_pubmethodDistinct<Char>(IEqualityComparer<Char>)

多載。從序列傳回不同的項目,使用指定的 IEqualityComparer<'T> 來比較值。(由 Enumerable 定義。)

System_CAPS_pubmethodElementAt<Char>(Int32)

傳回序列中的指定索引處的項目。(由 Enumerable 定義。)

System_CAPS_pubmethodElementAtOrDefault<Char>(Int32)

傳回位於序列中指定索引處的元素;如果索引超出範圍,則傳回預設值。(由 Enumerable 定義。)

System_CAPS_pubmethodExcept<Char>(IEnumerable<Char>)

多載。使用預設相等比較子來比較值,會產生兩個序列的差異。(由 Enumerable 定義。)

System_CAPS_pubmethodExcept<Char>(IEnumerable<Char>, IEqualityComparer<Char>)

多載。使用指定的產生兩個序列的差異 IEqualityComparer<'T> 來比較值。(由 Enumerable 定義。)

System_CAPS_pubmethodFirst<Char>()

多載。傳回序列的第一個項目。(由 Enumerable 定義。)

System_CAPS_pubmethodFirst<Char>(Func<Char, Boolean>)

多載。傳回序列中符合指定條件的第一個元素。(由 Enumerable 定義。)

System_CAPS_pubmethodFirstOrDefault<Char>()

多載。傳回序列的第一個元素;如果序列中沒有包含任何元素,則傳回預設值。(由 Enumerable 定義。)

System_CAPS_pubmethodFirstOrDefault<Char>(Func<Char, Boolean>)

多載。傳回序列中符合條件的第一個元素;如果找不到這類元素,則傳回預設值。(由 Enumerable 定義。)

System_CAPS_pubmethodGroupBy<Char, 'TKey>(Func<Char, 'TKey>)

多載。群組依據指定的索引鍵選取器函式序列的項目。(由 Enumerable 定義。)

System_CAPS_pubmethodGroupBy<Char, 'TKey>(Func<Char, 'TKey>, IEqualityComparer<'TKey>)

多載。群組的順序,根據指定的索引鍵選取器函式和比較使用指定的比較子索引鍵的項目。(由 Enumerable 定義。)

System_CAPS_pubmethodGroupBy<Char, 'TKey, 'TElement>(Func<Char, 'TKey>, Func<Char, 'TElement>)

多載。群組依據指定的索引鍵選取器函式並使用指定的函式的每個群組的項目序列的項目。(由 Enumerable 定義。)

System_CAPS_pubmethodGroupBy<Char, 'TKey, 'TElement>(Func<Char, 'TKey>, Func<Char, 'TElement>, IEqualityComparer<'TKey>)

多載。群組依據索引鍵選取器函式序列的項目。 索引鍵是使用比較子來進行比較,而每個群組的項目都是利用指定的函式進行投影。(由 Enumerable 定義。)

System_CAPS_pubmethodGroupBy<Char, 'TKey, 'TResult>(Func<Char, 'TKey>, Func<'TKey, IEnumerable<Char>, 'TResult>)

多載。依據指定的索引鍵選取器函式來群組序列的項目,並從每個群組及其索引鍵建立結果值。(由 Enumerable 定義。)

System_CAPS_pubmethodGroupBy<Char, 'TKey, 'TResult>(Func<Char, 'TKey>, Func<'TKey, IEnumerable<Char>, 'TResult>, IEqualityComparer<'TKey>)

多載。依據指定的索引鍵選取器函式來群組序列的項目,並從每個群組及其索引鍵建立結果值。 索引鍵是使用指定的比較子來進行比較。(由 Enumerable 定義。)

System_CAPS_pubmethodGroupBy<Char, 'TKey, 'TElement, 'TResult>(Func<Char, 'TKey>, Func<Char, 'TElement>, Func<'TKey, IEnumerable<'TElement>, 'TResult>)

多載。依據指定的索引鍵選取器函式來群組序列的項目,並從每個群組及其索引鍵建立結果值。 每個群組的項目都是利用指定的函式進行投影。(由 Enumerable 定義。)

System_CAPS_pubmethodGroupBy<Char, 'TKey, 'TElement, 'TResult>(Func<Char, 'TKey>, Func<Char, 'TElement>, Func<'TKey, IEnumerable<'TElement>, 'TResult>, IEqualityComparer<'TKey>)

多載。依據指定的索引鍵選取器函式來群組序列的項目,並從每個群組及其索引鍵建立結果值。 索引鍵值是使用指定的比較子來進行比較,而每個群組的項目則都是利用指定的函式進行投影。(由 Enumerable 定義。)

System_CAPS_pubmethodGroupJoin<Char, 'TInner, 'TKey, 'TResult>(IEnumerable<'TInner>, Func<Char, 'TKey>, Func<'TInner, 'TKey>, Func<Char, IEnumerable<'TInner>, 'TResult>)

多載。根據索引鍵相等的兩個序列的項目相互關聯,並將結果分組。 預設的相等比較子是用於比較索引鍵。(由 Enumerable 定義。)

System_CAPS_pubmethodGroupJoin<Char, 'TInner, 'TKey, 'TResult>(IEnumerable<'TInner>, Func<Char, 'TKey>, Func<'TInner, 'TKey>, Func<Char, IEnumerable<'TInner>, 'TResult>, IEqualityComparer<'TKey>)

多載。根據索引鍵相等的兩個序列的項目相互關聯,並將結果分組。 指定 IEqualityComparer<'T> 用於比較索引鍵。(由 Enumerable 定義。)

System_CAPS_pubmethodIntersect<Char>(IEnumerable<Char>)

多載。使用預設相等比較子來比較值,會產生兩個序列的交集。(由 Enumerable 定義。)

System_CAPS_pubmethodIntersect<Char>(IEnumerable<Char>, IEqualityComparer<Char>)

多載。使用指定的產生兩個序列的交集 IEqualityComparer<'T> 來比較值。(由 Enumerable 定義。)

System_CAPS_pubmethodJoin<Char, 'TInner, 'TKey, 'TResult>(IEnumerable<'TInner>, Func<Char, 'TKey>, Func<'TInner, 'TKey>, Func<Char, 'TInner, 'TResult>)

多載。根據相符索引鍵的兩個序列的項目相互關聯。 預設的相等比較子是用於比較索引鍵。(由 Enumerable 定義。)

System_CAPS_pubmethodJoin<Char, 'TInner, 'TKey, 'TResult>(IEnumerable<'TInner>, Func<Char, 'TKey>, Func<'TInner, 'TKey>, Func<Char, 'TInner, 'TResult>, IEqualityComparer<'TKey>)

多載。根據相符索引鍵的兩個序列的項目相互關聯。 指定 IEqualityComparer<'T> 用於比較索引鍵。(由 Enumerable 定義。)

System_CAPS_pubmethodLast<Char>()

多載。傳回序列的最後一個項目。(由 Enumerable 定義。)

System_CAPS_pubmethodLast<Char>(Func<Char, Boolean>)

多載。傳回序列中符合指定之條件的最後一個元素。(由 Enumerable 定義。)

System_CAPS_pubmethodLastOrDefault<Char>()

多載。傳回序列的最後一個元素;如果序列中沒有包含任何元素,則傳回預設值。(由 Enumerable 定義。)

System_CAPS_pubmethodLastOrDefault<Char>(Func<Char, Boolean>)

多載。傳回序列中符合條件的最後一個元素;如果找不到這類元素,則傳回預設值。(由 Enumerable 定義。)

System_CAPS_pubmethodLongCount<Char>()

多載。傳回 Int64 ,代表序列中的項目總數。(由 Enumerable 定義。)

System_CAPS_pubmethodLongCount<Char>(Func<Char, Boolean>)

多載。傳回 Int64 ,代表符合條件的序列中的項目數目。(由 Enumerable 定義。)

System_CAPS_pubmethodMax<Char>()

多載。傳回泛型序列中的最大值。(由 Enumerable 定義。)

System_CAPS_pubmethodMax<Char>(Func<Char, Decimal>)

多載。叫用轉換函式上序列的每個項目,並傳回最大 Decimal 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMax<Char>(Func<Char, Double>)

多載。叫用轉換函式上序列的每個項目,並傳回最大 Double 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMax<Char>(Func<Char, Int32>)

多載。叫用轉換函式上序列的每個項目,並傳回最大 Int32 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMax<Char>(Func<Char, Int64>)

多載。叫用轉換函式上序列的每個項目,並傳回最大 Int64 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMax<Char>(Func<Char, Nullable<Decimal>>)

多載。叫用轉換函式上序列的每個項目,並傳回最大值為 null Decimal 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMax<Char>(Func<Char, Nullable<Double>>)

多載。叫用轉換函式上序列的每個項目,並傳回最大值為 null Double 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMax<Char>(Func<Char, Nullable<Int32>>)

多載。叫用轉換函式上序列的每個項目,並傳回最大值為 null Int32 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMax<Char>(Func<Char, Nullable<Int64>>)

多載。叫用轉換函式上序列的每個項目,並傳回最大值為 null Int64 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMax<Char>(Func<Char, Nullable<Single>>)

多載。叫用轉換函式上序列的每個項目,並傳回最大值為 null Single 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMax<Char>(Func<Char, Single>)

多載。叫用轉換函式上序列的每個項目,並傳回最大 Single 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMax<Char, 'TResult>(Func<Char, 'TResult>)

多載。叫用轉換函式的泛型序列的每個項目並傳回產生的最大值。(由 Enumerable 定義。)

System_CAPS_pubmethodMin<Char>()

多載。傳回泛型序列中的最小值。(由 Enumerable 定義。)

System_CAPS_pubmethodMin<Char>(Func<Char, Decimal>)

多載。叫用轉換函式上序列的每個項目,並傳回最小值 Decimal 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMin<Char>(Func<Char, Double>)

多載。叫用轉換函式上序列的每個項目,並傳回最小值 Double 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMin<Char>(Func<Char, Int32>)

多載。叫用轉換函式上序列的每個項目,並傳回最小值 Int32 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMin<Char>(Func<Char, Int64>)

多載。叫用轉換函式上序列的每個項目,並傳回最小值 Int64 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMin<Char>(Func<Char, Nullable<Decimal>>)

多載。叫用轉換函式上序列的每個項目,並傳回最小值為 null Decimal 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMin<Char>(Func<Char, Nullable<Double>>)

多載。叫用轉換函式上序列的每個項目,並傳回最小值為 null Double 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMin<Char>(Func<Char, Nullable<Int32>>)

多載。叫用轉換函式上序列的每個項目,並傳回最小值為 null Int32 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMin<Char>(Func<Char, Nullable<Int64>>)

多載。叫用轉換函式上序列的每個項目,並傳回最小值為 null Int64 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMin<Char>(Func<Char, Nullable<Single>>)

多載。叫用轉換函式上序列的每個項目,並傳回最小值為 null Single 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMin<Char>(Func<Char, Single>)

多載。叫用轉換函式上序列的每個項目,並傳回最小值 Single 值。(由 Enumerable 定義。)

System_CAPS_pubmethodMin<Char, 'TResult>(Func<Char, 'TResult>)

多載。叫用轉換函式的泛型序列的每個項目並傳回產生的最小值。(由 Enumerable 定義。)

System_CAPS_pubmethodOfType<'TResult>()

篩選的項目 IEnumerable 根據指定的型別。(由 Enumerable 定義。)

System_CAPS_pubmethodOrderBy<Char, 'TKey>(Func<Char, 'TKey>)

多載。排序序列中遞增順序依據索引鍵的項目。(由 Enumerable 定義。)

System_CAPS_pubmethodOrderBy<Char, 'TKey>(Func<Char, 'TKey>, IComparer<'TKey>)

多載。排序序列中使用指定的比較子,依遞增順序排列的項目。(由 Enumerable 定義。)

System_CAPS_pubmethodOrderByDescending<Char, 'TKey>(Func<Char, 'TKey>)

多載。排序序列中遞減的順序,根據索引鍵的項目。(由 Enumerable 定義。)

System_CAPS_pubmethodOrderByDescending<Char, 'TKey>(Func<Char, 'TKey>, IComparer<'TKey>)

多載。使用指定的比較子,依遞減順序排序序列中的項目。(由 Enumerable 定義。)

System_CAPS_pubmethodReverse<Char>()

反轉序列中項目的順序。(由 Enumerable 定義。)

System_CAPS_pubmethodSelect<Char, 'TResult>(Func<Char, 'TResult>)

多載。將序列的每個元素規劃成一個新的表單。(由 Enumerable 定義。)

System_CAPS_pubmethodSelect<Char, 'TResult>(Func<Char, Int32, 'TResult>)

多載。投射成新的表單序列的每個項目所加入的項目索引。(由 Enumerable 定義。)

System_CAPS_pubmethodSelectMany<Char, 'TResult>(Func<Char, IEnumerable<'TResult>>)

多載。每個序列的項目至 IEnumerable<'T> 並壓平合併成單一序列產生的序列。(由 Enumerable 定義。)

System_CAPS_pubmethodSelectMany<Char, 'TResult>(Func<Char, Int32, IEnumerable<'TResult>>)

多載。每個序列的項目至 IEnumerable<'T>, ,並將簡化成單一序列產生的序列。 各來源項目的索引是在該項目的投影表單中使用。(由 Enumerable 定義。)

System_CAPS_pubmethodSelectMany<Char, 'TCollection, 'TResult>(Func<Char, IEnumerable<'TCollection>>, Func<Char, 'TCollection, 'TResult>)

多載。每個序列的項目至 IEnumerable<'T>, 壓平合併成單一序列,產生的序列,其中將每個項目中的結果選取器函式會叫用。(由 Enumerable 定義。)

System_CAPS_pubmethodSelectMany<Char, 'TCollection, 'TResult>(Func<Char, Int32, IEnumerable<'TCollection>>, Func<Char, 'TCollection, 'TResult>)

多載。每個序列的項目至 IEnumerable<'T>, 壓平合併成單一序列,產生的序列,其中將每個項目中的結果選取器函式會叫用。 各來源項目的索引是在該項目的中繼投影表單中使用。(由 Enumerable 定義。)

System_CAPS_pubmethodSequenceEqual<Char>(IEnumerable<Char>)

多載。判斷兩個序列是否相等來比較項目之類型使用預設相等比較子。(由 Enumerable 定義。)

System_CAPS_pubmethodSequenceEqual<Char>(IEnumerable<Char>, IEqualityComparer<Char>)

多載。判斷兩個序列是否相等比較其項目,使用指定的 IEqualityComparer<'T>(由 Enumerable 定義。)

System_CAPS_pubmethodSingle<Char>()

多載。傳回序列的唯一一個元素,如果序列中不是正好一個元素,則擲回例外狀況。(由 Enumerable 定義。)

System_CAPS_pubmethodSingle<Char>(Func<Char, Boolean>)

多載。傳回序列中符合指定之條件的唯一一個元素,如果有一個以上這類元素,則擲回例外狀況。(由 Enumerable 定義。)

System_CAPS_pubmethodSingleOrDefault<Char>()

多載。傳回的唯一項目序列或預設值,如果序列是空的。如果序列中有多個項目,則這個方法會擲回例外狀況。(由 Enumerable 定義。)

System_CAPS_pubmethodSingleOrDefault<Char>(Func<Char, Boolean>)

多載。傳回序列中符合指定之條件的唯一一個元素,如果沒有這類元素,則為預設值,如果有一個以上的元素符合條件,這個方法就會擲回例外狀況。(由 Enumerable 定義。)

System_CAPS_pubmethodSkip<Char>(Int32)

略過指定的數目的序列中的項目,然後傳回其餘項目。(由 Enumerable 定義。)

System_CAPS_pubmethodSkipWhile<Char>(Func<Char, Boolean>)

多載。只要指定的條件為 true,然後傳回其餘項目,請略過序列中的項目。(由 Enumerable 定義。)

System_CAPS_pubmethodSkipWhile<Char>(Func<Char, Int32, Boolean>)

多載。只要指定的條件為 true,然後傳回其餘項目,請略過序列中的項目。 項目的索引是用於述詞功能的邏輯中。(由 Enumerable 定義。)

System_CAPS_pubmethodSum<Char>(Func<Char, Decimal>)

多載。計算序列的總和 Decimal 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodSum<Char>(Func<Char, Double>)

多載。計算序列的總和 Double 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodSum<Char>(Func<Char, Int32>)

多載。計算序列的總和 Int32 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodSum<Char>(Func<Char, Int64>)

多載。計算序列的總和 Int64 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodSum<Char>(Func<Char, Nullable<Decimal>>)

多載。可為 null 的序列的總和 Decimal 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodSum<Char>(Func<Char, Nullable<Double>>)

多載。可為 null 的序列的總和 Double 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodSum<Char>(Func<Char, Nullable<Int32>>)

多載。可為 null 的序列的總和 Int32 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodSum<Char>(Func<Char, Nullable<Int64>>)

多載。可為 null 的序列的總和 Int64 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodSum<Char>(Func<Char, Nullable<Single>>)

多載。可為 null 的序列的總和 Single 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodSum<Char>(Func<Char, Single>)

多載。計算序列的總和 Single 叫用轉換函式的輸入序列的每個項目上所取得的值。(由 Enumerable 定義。)

System_CAPS_pubmethodTake<Char>(Int32)

從序列開頭傳回指定的連續的項目數。(由 Enumerable 定義。)

System_CAPS_pubmethodTakeWhile<Char>(Func<Char, Boolean>)

多載。傳回序列中的項目,只要指定的條件為真。(由 Enumerable 定義。)

System_CAPS_pubmethodTakeWhile<Char>(Func<Char, Int32, Boolean>)

多載。傳回序列中的項目,只要指定的條件為真。 項目的索引是用於述詞功能的邏輯中。(由 Enumerable 定義。)

System_CAPS_pubmethodToArray<Char>()

建立陣列,從 IEnumerable<'T>(由 Enumerable 定義。)

System_CAPS_pubmethodToDictionary<Char, 'TKey>(Func<Char, 'TKey>)

多載。建立 Dictionary<'TKey, 'TValue>IEnumerable<'T> 依據指定的索引鍵選取器函式。(由 Enumerable 定義。)

System_CAPS_pubmethodToDictionary<Char, 'TKey>(Func<Char, 'TKey>, IEqualityComparer<'TKey>)

多載。建立 Dictionary<'TKey, 'TValue>IEnumerable<'T> 根據指定的索引鍵選取器函式和索引鍵比較子。(由 Enumerable 定義。)

System_CAPS_pubmethodToDictionary<Char, 'TKey, 'TElement>(Func<Char, 'TKey>, Func<Char, 'TElement>)

多載。建立 Dictionary<'TKey, 'TValue>IEnumerable<'T> 根據指定的索引鍵選取器和項目選取器函式。(由 Enumerable 定義。)

System_CAPS_pubmethodToDictionary<Char, 'TKey, 'TElement>(Func<Char, 'TKey>, Func<Char, 'TElement>, IEqualityComparer<'TKey>)

多載。建立 Dictionary<'TKey, 'TValue>IEnumerable<'T> 根據指定的索引鍵選取器函式、 比較子和項目選取器函式。(由 Enumerable 定義。)

System_CAPS_pubmethodToList<Char>()

建立 List<'T>IEnumerable<'T>(由 Enumerable 定義。)

System_CAPS_pubmethodToLookup<Char, 'TKey>(Func<Char, 'TKey>)

多載。建立 Lookup<'TKey, 'TElement>IEnumerable<'T> 依據指定的索引鍵選取器函式。(由 Enumerable 定義。)

System_CAPS_pubmethodToLookup<Char, 'TKey>(Func<Char, 'TKey>, IEqualityComparer<'TKey>)

多載。建立 Lookup<'TKey, 'TElement>IEnumerable<'T> 根據指定的索引鍵選取器函式和索引鍵比較子。(由 Enumerable 定義。)

System_CAPS_pubmethodToLookup<Char, 'TKey, 'TElement>(Func<Char, 'TKey>, Func<Char, 'TElement>)

多載。建立 Lookup<'TKey, 'TElement>IEnumerable<'T> 根據指定的索引鍵選取器和項目選取器函式。(由 Enumerable 定義。)

System_CAPS_pubmethodToLookup<Char, 'TKey, 'TElement>(Func<Char, 'TKey>, Func<Char, 'TElement>, IEqualityComparer<'TKey>)

多載。建立 Lookup<'TKey, 'TElement>IEnumerable<'T> 根據指定的索引鍵選取器函式、 比較子和項目選取器函式。(由 Enumerable 定義。)

System_CAPS_pubmethodUnion<Char>(IEnumerable<Char>)

多載。使用預設相等比較子,以產生兩個序列的聯集。(由 Enumerable 定義。)

System_CAPS_pubmethodUnion<Char>(IEnumerable<Char>, IEqualityComparer<Char>)

多載。使用指定之產生兩個序列的聯集 IEqualityComparer<'T>(由 Enumerable 定義。)

System_CAPS_pubmethodWhere<Char>(Func<Char, Boolean>)

多載。根據述詞來篩選值序列。(由 Enumerable 定義。)

System_CAPS_pubmethodWhere<Char>(Func<Char, Int32, Boolean>)

多載。根據述詞來篩選值序列。 述詞函式的邏輯中使用各項目的索引。(由 Enumerable 定義。)

System_CAPS_pubmethodZip<Char, 'TSecond, 'TResult>(IEnumerable<'TSecond>, Func<Char, 'TSecond, 'TResult>)

適用於兩個序列,產生之結果的序列的對應項目指定的函式。(由 Enumerable 定義。)

System_CAPS_note注意

To view the .NET Framework source code for this type, see the Reference Sourcehttp://referencesource.microsoft.com/#mscorlib/system/string.cs#8281103e6f23cb5c. You can browse through the source code online, download the reference for offline viewing, and step through the sources (including patches and updates) during debugging; see instructionshttp://referencesource.microsoft.com/.

A string is a sequential collection of characters that is used to represent text. A T:System.String object is a sequential collection of T:System.Char objects that represent a string; a T:System.Char object corresponds to a UTF-16 code unit. The value of the T:System.String object is the content of the sequential collection of T:System.Char objects, and that value is immutable (that is, it is read-only). For more information about the immutability of strings, see the Immutability and the StringBuilder class section later in this topic. The maximum size of a T:System.String object in memory is 2GB, or about 1 billion characters.

In this section:

Instantiating a String object
Char objects and Unicode characters
Strings and The Unicode Standard
Strings and embedded null characters
Strings and indexes
Null strings and empty strings
Immutability and the StringBuilder class
Ordinal vs. culture-sensitive operations
Normalization
String operations by category

You can instantiate a T:System.String object in the following ways:

  • By assigning a string literal to a T:System.String variable. This is the most commonly used method for creating a string. The following example uses assignment to create several strings. Note that in C#, because the backslash (\) is an escape character, literal backslashes in a string must be escaped or the entire string must be @-quoted.

    No code example is currently available or this language may not be supported.
  • By calling a T:System.String class constructor. The following example instantiates strings by calling several class constructors. Note that some of the constructors include pointers to character arrays or signed byte arrays as parameters. Visual Basic does not support calls to these constructors. For detailed information about T:System.String constructors, see the Overload:System.String.#ctor constructor summary.

    No code example is currently available or this language may not be supported.
  • By using the string concatenation operator (+ in C# and & or + in Visual Basic) to create a single string from any combination of T:System.String instances and string literals. The following example illustrates the use of the string concatenation operator.

    No code example is currently available or this language may not be supported.
  • By retrieving a property or calling a method that returns a string. The following example uses the methods of the T:System.String class to extract a substring from a larger string.

    No code example is currently available or this language may not be supported.
  • By calling a formatting method to convert a value or object to its string representation. The following example uses the composite formatting feature to embed the string representation of two objects into a string.

    No code example is currently available or this language may not be supported.

Each character in a string is defined by a Unicode scalar value, also called a Unicode code point or the ordinal (numeric) value of the Unicode character. Each code point is encoded by using UTF-16 encoding, and the numeric value of each element of the encoding is represented by a T:System.Char object.

System_CAPS_note注意

Note that, because a T:System.String instance consists of a sequential collection of UTF-16 code units, it is possible to create a T:System.String object that is not a well-formed Unicode string. For example, it is possible to create a string that has a low surrogate without a corresponding high surrogate. Although some methods, such as the methods of encoding and decoding objects in the N:System.Text namespace, may performs checks to ensure that strings are well-formed, T:System.String class members do not ensure that a string is well-formed.

A single T:System.Char object usually represents a single code point; that is, the numeric value of the T:System.Char equals the code point. For example, the code point for the character "a" is U+0061. However, a code point might require more than one encoded element (more than one T:System.Char object). The Unicode standard defines two types of characters that correspond to multiple T:System.Char objects: graphemes, and Unicode supplementary code points that correspond to characters in the Unicode supplementary planes.

  • A grapheme is represented by a base character followed by one or more combining characters. For example, the character ä is represented by a T:System.Char object whose code point is U+0061 followed by a T:System.Char object whose code point is U+0308. This character can also be defined by a single T:System.Char object that has a code point of U+00E4. As the following example shows, a culture-sensitive comparison for equality indicates that these two representations are equal, although an ordinary ordinal comparison does not. However, if the two strings are normalized, an ordinal comparison also indicates that they are equal. (For more information on normalizing strings, see the Normalization section.)

    No code example is currently available or this language may not be supported.
  • A Unicode supplementary code point (a surrogate pair) is represented by a T:System.Char object whose code point is a high surrogate followed by a T:System.Char object whose code point is a low surrogate. The code units of high surrogates range from U+D800 to U+DBFF. The code units of low surrogates range from U+DC00 to U+DFFF. Surrogate pairs are used to represent characters in the 16 Unicode supplementary planes. The following example creates a surrogate character and passes it to the M:System.Char.IsSurrogatePair(System.Char,System.Char) method to determine whether it is a surrogate pair.

    No code example is currently available or this language may not be supported.

Characters in a string are represented by UTF-16 encoded code units, which correspond to T:System.Char values.

Each character in a string has an associated Unicode character category, which is represented in the .NET Framework by the T:System.Globalization.UnicodeCategory enumeration. The category of a character or a surrogate pair can be determined by calling the M:System.Globalization.CharUnicodeInfo.GetUnicodeCategory(System.Char) method.

The .NET Framework maintains its own table of characters and their corresponding categories, which ensures that a version of the .NET Framework running on different platforms returns identical character category information. The following table lists the versions of the .NET Framework and the versions of the Unicode Standard on which their character categories are based.

.NET Framework version

Version of the Unicode Standard

.NET Framework 1.1

The Unicode Standard, Version 4.0.0

The .NET Framework 2.0

The Unicode Standard, Version 5.0.0

.NET Framework 3.5

The Unicode Standard, Version 5.0.0

.NET Framework 4

The Unicode Standard, Version 5.0.0

.NET Framework 4.5

The Unicode Standard, Version 6.3.0

.NET Framework 4.5.1

The Unicode Standard, Version 6.3.0

.NET Framework 4.5.2

The Unicode Standard, Version 6.3.0

.NET Framework 4.6

The Unicode Standard, Version 6.3.0

.NET Framework 4.6.1

The Unicode Standard, Version 6.3.0

.NET Framework 4.6.2

The Unicode Standard, Version 8.0.0

In addition, the .NET Framework supports string comparison and sorting based on the Unicode standard. In versions of the .NET Framework through the net_v40_long, the .NET Framework maintains its own table of string data. This is also true of versions of the .NET Framework starting with the net_v45 running on Windows 7. Starting with the net_v45 running on Window 8 and later versions of the Windows operating system, the runtime delegates string comparison and sorting operations to the operating system. The following table lists the versions of the .NET Framework and the versions of the Unicode Standard on which character comparison and sorting are based.

.NET Framework version

Version of the Unicode Standard

.NET Framework 1.1

The Unicode Standard, Version 4.0.0

The .NET Framework 2.0

The Unicode Standard, Version 5.0.0

.NET Framework 3.5

The Unicode Standard, Version 5.0.0

.NET Framework 4

The Unicode Standard, Version 5.0.0

.NET Framework 4.5 and later on Windows 7

The Unicode Standard, Version 5.0.0

.NET Framework 4.5 and later on Windows 8 and later Windows operating systems

The Unicode Standard, Version 6.3.0

In the .NET Framework, a T:System.String object can include embedded null characters, which count as a part of the string's length. However, in some languages such as C and C++, a null character indicates the end of a string;it is not considered a part of the string and is not counted as part of the string's length. This means that the following common assumptions that C and C++ programmers or libraries written in C or C++ might make about strings are not necessarily valid when applied to T:System.String objects:

  • The value returned by the strlen or wcslen functions does not necessarily equal P:System.String.Length.

  • The string created by the strcpy_s or wcscpy_s functions is not necessarily identical to the string created by the M:System.String.Copy(System.String) method.

You should ensure that native C and C++ code that instantiates T:System.String objects, and code that is passed T:System.String objects through platform invoke, do not assume that an embedded null character marks the end of the string.

Embedded null characters in a string are also treated differently when a string is sorted (or compared) and when a string is searched. Null characters are ignored when performing culture-sensitive comparisons between two strings, including comparisons using the invariant culture. They are considered only for ordinal or case-insensitive ordinal comparisons. On the other hand, embedded null characters are always considered when searching a string with methods such as M:System.String.Contains(System.String), M:System.String.StartsWith(System.String), and M:System.String.IndexOf(System.String).

An index is the position of a T:System.Char object (not a Unicode character) in a T:System.String. An index is a zero-based, nonnegative number that starts from the first position in the string, which is index position zero. A number of search methods, such as M:System.String.IndexOf(System.Char) and M:System.String.LastIndexOf(System.Char), return the index of a character or substring in the string instance.

The P:System.String.Chars(System.Int32) property lets you access individual T:System.Char objects by their index position in the string. Because the P:System.String.Chars(System.Int32) property is the default property (in Visual Basic) or the indexer (in C#), you can access the individual T:System.Char objects in a string by using code such as the following. This code looks for white space or punctuation characters in a string to determine how many words the string contains.

No code example is currently available or this language may not be supported.

Because the T:System.String class implements the T:System.Collections.IEnumerable interface, you can also iterate through the T:System.Char objects in a string by using a foreach construct, as the following example shows.

No code example is currently available or this language may not be supported.

Consecutive index values might not correspond to consecutive Unicode characters, because a Unicode character might be encoded as more than one T:System.Char object. In particular, a string may contain multi-character units of text that are formed by a base character followed by one or more combining characters or by surrogate pairs. To work with Unicode characters instead of T:System.Char objects, use the T:System.Globalization.StringInfo and T:System.Globalization.TextElementEnumerator classes. The following example illustrates the difference between code that works with T:System.Char objects and code that works with Unicode characters. It compares the number of characters or text elements in each word of a sentence. The string includes two sequences of a base character followed by a combining character.

No code example is currently available or this language may not be supported.

This example works with text elements by using the M:System.Globalization.StringInfo.GetTextElementEnumerator(System.String) method and the T:System.Globalization.TextElementEnumerator class to enumerate all the text elements in a string. You can also retrieve an array that contains the starting index of each text element by calling the M:System.Globalization.StringInfo.ParseCombiningCharacters(System.String) method.

For more information about working with units of text rather than individual T:System.Char values, see the T:System.Globalization.StringInfo class.

A string that has been declared but has not been assigned a value is null. Attempting to call methods on that string throws a T:System.NullReferenceException. A null string is different from an empty string, which is a string whose value is "" or F:System.String.Empty. In some cases, passing either a null string or an empty string as an argument in a method call throws an exception. For example, passing a null string to the M:System.Int32.Parse(System.String) method throws an T:System.ArgumentNullException, and passing an empty string throws a T:System.FormatException. In other cases, a method argument can be either a null string or an empty string. For example, if you are providing an T:System.IFormattable implementation for a class, you want to equate both a null string and an empty string with the general ("G") format specifier.

The T:System.String class includes the following two convenience methods that enable you to test whether a string is null or empty:

  • IsNullOrEmpty, which indicates whether a string is either null or is equal to String.Empty. This method eliminates the need to use code such as the following:

    No code example is currently available or this language may not be supported.
  • IsNullOrWhiteSpace, which indicates whether a string is null, equals String.Empty, or consists exclusively of white-space characters. This method eliminates the need to use code such as the following:

    No code example is currently available or this language may not be supported.

The following example uses the M:System.String.IsNullOrEmpty(System.String) method in the M:System.IFormattable.ToString(System.String,System.IFormatProvider) implementation of a custom Temperature class. The method supports the "G", "C", "F", and "K" format strings. If an empty format string or a format string whose value is null is passed to the method, its value is changed to the "G" format string.

No code example is currently available or this language may not be supported.

A T:System.String object is called immutable (read-only), because its value cannot be modified after it has been created. Methods that appear to modify a T:System.String object actually return a new T:System.String object that contains the modification.

Because strings are immutable, string manipulation routines that perform repeated additions or deletions to what appears to be a single string can exact a significant performance penalty. For example, the following code uses a random number generator to create a string with 1000 characters in the range 0x0001 to 0x052F. Although the code appears to use string concatenation to append a new character to the existing string named str, it actually creates a new T:System.String object for each concatenation operation.

No code example is currently available or this language may not be supported.

You can use the T:System.Text.StringBuilder class instead of the T:System.String class for operations that make multiple changes to the value of a string. Unlike instances of the T:System.String class, T:System.Text.StringBuilder objects are mutable; when you concatenate, append, or delete substrings from a string, the operations are performed on a single string. When you have finished modifying the value of a T:System.Text.StringBuilder object, you can call its M:System.Text.StringBuilder.ToString method to convert it to a string. The following example replaces the T:System.String used in the previous example to concatenate 1000 random characters in the range to 0x0001 to 0x052F with a T:System.Text.StringBuilder object.

No code example is currently available or this language may not be supported.

Members of the T:System.String class perform either ordinal or culture-sensitive (linguistic) operations on a T:System.String object. An ordinal operation acts on the numeric value of each T:System.Char object. A culture-sensitive operation acts on the value of the T:System.Stringobject, and takes culture-specific casing, sorting, formatting, and parsing rules into account. Culture-sensitive operations execute in the context of an explicitly declared culture or the implicit current culture. The two kinds of operations can produce very different results when they are performed on the same string.

The .NET Framework also supports culture-insensitive linguistic string operations by using the invariant culture (P:System.Globalization.CultureInfo.InvariantCulture), which is loosely based on the culture settings of the English language independent of region. Unlike other T:System.Globalization.CultureInfo settings, the settings of the invariant culture are guaranteed to remain consistent on a single computer, from system to system, and across versions of the .NET Framework. The invariant culture can be seen as a kind of black box that ensures stability of string comparisons and ordering across all cultures.

System_CAPS_security 安全性 注意

If your application makes a security decision about a symbolic identifier such as a file name or named pipe, or about persisted data such as the text-based data in an XML file, the operation should use an ordinal comparison instead of a culture-sensitive comparison. This is because a culture-sensitive comparison can yield different results depending on the culture in effect, whereas an ordinal comparison depends solely on the binary value of the compared characters.

System_CAPS_important重要

Most methods that perform string operations include an overload that has a parameter of type T:System.StringComparison, which enables you to specify whether the method performs an ordinal or culture-sensitive operation. In general, you should call this overload to make the intent of your method call clear. For best practices and guidance for using ordinal and culture-sensitive operations on strings, see Best Practices for Using Strings in the .NET Framework.

Operations for casing, parsing and formatting, comparison and sorting, and testing for equality can be either ordinal or culture-sensitive. The following sections discuss each category of operation.

System_CAPS_tip提示

You should always call a method overload that makes the intent of your method call clear. For example, instead of calling the M:System.String.Compare(System.String,System.String) method to perform a culture-sensitive comparison of two strings by using the conventions of the current culture, you should call the M:System.String.Compare(System.String,System.String,System.StringComparison) method with a value of F:System.StringComparison.CurrentCulture for the comparisonType argument. For more information, see Best Practices for Using Strings in the .NET Framework.

Casing rules determine how to change the capitalization of a Unicode character; for example, from lowercase to uppercase. Often, a casing operation is performed before a string comparison. For example, a string might be converted to uppercase so that it can be compared with another uppercase string. You can convert the characters in a string to lowercase by calling the M:System.String.ToLower or M:System.String.ToLowerInvariant method, and you can convert them to uppercase by calling the M:System.String.ToUpper or M:System.String.ToUpperInvariant method. In addition, you can use the M:System.Globalization.TextInfo.ToTitleCase(System.String) method to convert a string to title case.

Casing operations can be based on the rules of the current culture, a specified culture, or the invariant culture. Because case mappings can vary depending on the culture used, the result of casing operations can vary based on culture. The actual differences in casing are of three kinds:

  • Differences in the case mapping of LATIN CAPITAL LETTER I (U+0049), LATIN SMALL LETTER I (U+0069), LATIN CAPITAL LETTER I WITH DOT ABOVE (U+0130), and LATIN SMALL LETTER DOTLESS I (U+0131). In the tr-TR (Turkish (Turkey)) and az-Latn-AZ (Azerbaijan, Latin) cultures, and in the tr, az, and az-Latn neutral cultures, the lowercase equivalent of LATIN CAPITAL LETTER I is LATIN SMALL LETTER DOTLESS I, and the uppercase equivalent of LATIN SMALL LETTER I is LATIN CAPITAL LETTER I WITH DOT ABOVE. In all other cultures, including the invariant culture, LATIN SMALL LETTER I and LATIN CAPITAL LETTER I are lowercase and uppercase equivalents.

    The following example demonstrates how a string comparison designed to prevent file system access can fail if it relies on a culture-sensitive casing comparison. (The casing conventions of the invariant culture should have been used.)

    No code example is currently available or this language may not be supported.
  • Differences in case mappings between the invariant culture and all other cultures. In these cases, using the casing rules of the invariant culture to change a character to uppercase or lowercase returns the same character. For all other cultures, it returns a different character. Some of the affected characters are listed in the following table.

    Character

    If changed to

    Returns

    MICRON SIGN (U+00B5)

    Uppercase

    GREEK CAPITAL LETTER MU (U+-39C)

    LATIN CAPITAL LETTER I WITH DOT ABOVE (U+0130)

    Lowercase

    LATIN SMALL LETTER I (U+0069)

    LATIN SMALL LETTER DOTLESS I (U+0131)

    Uppercase

    LATIN CAPITAL LETTER I (U+0049)

    LATIN SMALL LETTER LONG S (U+017F)

    Uppercase

    LATIN CAPITAL LETTER S (U+0053)

    LATIN CAPITAL LETTER D WITH SMALL LETTER Z WITH CARON (U+01C5)

    Lowercase

    LATIN SMALL LETTER DZ WITH CARON (U+01C6)

    COMBINING GREEK YPOGEGRAMMENI (U+0345)

    Uppercase

    GREEK CAPITAL LETTER IOTA (U+0399)

  • Differences in case mappings of two-letter mixed-case pairs in the ASCII character range. In most cultures, a two-letter mixed-case pair is equal to the equivalent two-letter uppercase or lowercase pair. This is not true for the following two-letter pairs in the following cultures, because in each case they are compared to a digraph:

    • "lJ" and "nJ" in the hr-HR (Croatian (Croatia)) culture.

    • "cH" in the cs-CZ (Czech (Czech Republic)) and sk-SK (Slovak (Slovakia)) cultures.

    • "aA" in the da-DK (Danish (Denmark)) culture.

    • "cS", "dZ", "dZS", "nY", "sZ", "tY", and "zS" in the hu-HU (Hungarian (Hungary)) culture.

    • "cH" and "lL" in the es-ES_tradnl (Spanish (Spain, Traditional Sort)) culture.

    • "cH", "gI", "kH", "nG" "nH", "pH", "qU', "tH", and "tR" in the vi-VN (Vietnamese (Vietnam)) culture.

    However, it is unusual to encounter a situation in which a culture-sensitive comparison of these pairs creates problems, because these pairs are uncommon in fixed strings or identifiers.

The following example illustrates some of the differences in casing rules between cultures when converting strings to uppercase.

No code example is currently available or this language may not be supported.

Formatting and parsing are inverse operations. Formatting rules determine how to convert a value, such as a date and time or a number, to its string representation, whereas parsing rules determine how to convert a string representation to a value such as a date and time. Both formatting and parsing rules are dependent on cultural conventions. The following example illustrates the ambiguity that can arise when interpreting a culture-specific date string. Without knowing the conventions of the culture that was used to produce a date string, it is not possible to know whether 03/01/2011, 3/1/2011, and 01/03/2011 represent January 3, 2011 or March 1, 2011.

No code example is currently available or this language may not be supported.

Similarly, as the following example shows, a single string can produce different dates depending on the culture whose conventions are used in the parsing operation.

No code example is currently available or this language may not be supported.

Conventions for comparing and sorting strings vary from culture to culture. For example, the sort order may be based on phonetics or on the visual representation of characters. In East Asian languages, characters are sorted by the stroke and radical of ideographs. Sorting also depends on the order languages and cultures use for the alphabet. For example, the Danish language has an "Æ" character that it sorts after "Z" in the alphabet. In addition, comparisons can be case-sensitive or case-insensitive, and in some cases casing rules also differ by culture. Ordinal comparison, on the other hand, uses the Unicode code points of individual characters in a string when comparing and sorting strings.

Sort rules determine the alphabetic order of Unicode characters and how two strings compare to each other. For example, the M:System.String.Compare(System.String,System.String,System.StringComparison) method compares two strings based on the T:System.StringComparison parameter. If the parameter value is F:System.StringComparison.CurrentCulture, the method performs a linguistic comparison that uses the conventions of the current culture; if the parameter value is F:System.StringComparison.Ordinal, the method performs an ordinal comparison. Consequently, as the following example shows, if the current culture is U.S. English, the first call to the M:System.String.Compare(System.String,System.String,System.StringComparison) method (using culture-sensitive comparison) considers "a" less than "A", but the second call to the same method (using ordinal comparison) considers "a" greater than "A".

No code example is currently available or this language may not be supported.

The .NET Framework supports word, string, and ordinal sort rules:

  • A word sort performs a culture-sensitive comparison of strings in which certain nonalphanumeric Unicode characters might have special weights assigned to them. For example, the hyphen (-) might have a very small weight assigned to it so that "coop" and "co-op" appear next to each other in a sorted list. For a list of the T:System.Stringmethods that compare two strings using word sort rules, see the String operations by category section.

  • A string sort also performs a culture-sensitive comparison. It is similar to a word sort, except that there are no special cases, and all nonalphanumeric symbols come before all alphanumeric Unicode characters. Two strings can be compared using string sort rules by calling the M:System.Globalization.CompareInfo.Compare(System.String,System.String) method overloads that have an options parameter that is supplied a value of F:System.Globalization.CompareOptions.StringSort. Note that this is the only method that the .NET Framework provides to compare two strings using string sort rules.

  • An ordinal sort compares strings based on the numeric value of each T:System.Char object in the string. An ordinal comparison is automatically case-sensitive because the lowercase and uppercase versions of a character have different code points. However, if case is not important, you can specify an ordinal comparison that ignores case. This is equivalent to converting the string to uppercase by using the invariant culture and then performing an ordinal comparison on the result. For a list of the T:System.String methods that compare two strings using ordinal sort rules, see the String operations by category section.

A culture-sensitive comparison is any comparison that explicitly or implicitly uses a T:System.Globalization.CultureInfo object, including the invariant culture that is specified by the P:System.Globalization.CultureInfo.InvariantCulture property. The implicit culture is the current culture, which is specified by the P:System.Threading.Thread.CurrentCulture and P:System.Globalization.CultureInfo.CurrentCulture properties. There is considerable variation in the sort order of alphabetic characters (that is, characters for which the M:System.Char.IsLetter(System.Char) property returns true) across cultures. You can specify a culture-sensitive comparison that uses the conventions of a specific culture by supplying a T:System.Globalization.CultureInfo object to a string comparison method such as M:System.String.Compare(System.String,System.String,System.Globalization.CultureInfo,System.Globalization.CompareOptions). You can specify a culture-sensitive comparison that uses the conventions of the current culture by supplying F:System.StringComparison.CurrentCulture, F:System.StringComparison.CurrentCultureIgnoreCase, or any member of the T:System.Globalization.CompareOptions enumeration other than F:System.Globalization.CompareOptions.Ordinal or F:System.Globalization.CompareOptions.OrdinalIgnoreCase to an appropriate overload of the M:System.String.Compare(System.String,System.String) method. A culture-sensitive comparison is generally appropriate for sorting whereas an ordinal comparison is not. An ordinal comparison is generally appropriate for determining whether two strings are equal (that is, for determining identity) whereas a culture-sensitive comparison is not.

The following example illustrates the difference between culture-sensitive and ordinal comparison. The example evaluates three strings, "Apple", "Æble", and "AEble", using ordinal comparison and the conventions of the da-DK and en-US cultures (each of which is the default culture at the time the M:System.String.Compare(System.String,System.String) method is called). Because the Danish language treats the character "Æ" as an individual letter and sorts it after "Z" in the alphabet, the string "Æble" is greater than "Apple". However, "Æble" is not considered equivalent to "AEble", so "Æble" is also greater than "AEble". The en-US culture doesn't include the letter"Æ" but treats it as equivalent to "AE", which explains why "Æble" is less than "Apple" but equal to "AEble". Ordinal comparison, on the other hand, considers "Apple" to be less than "Æble", and "Æble" to be greater than "AEble".

No code example is currently available or this language may not be supported.

Use the following general guidelines to choose an appropriate sorting or string comparison method:

  • If you want the strings to be ordered based on the user's culture, you should order them based on the conventions of the current culture. If the user's culture changes, the order of sorted strings will also change accordingly. For example, a thesaurus application should always sort words based on the user's culture.

  • If you want the strings to be ordered based on the conventions of a specific culture, you should order them by supplying a T:System.Globalization.CultureInfo object that represents that culture to a comparison method. For example, in an application designed to teach students a particular language, you want strings to be ordered based on the conventions of one of the cultures that speaks that language.

  • If you want the order of strings to remain unchanged across cultures, you should order them based on the conventions of the invariant culture or use an ordinal comparison. For example, you would use an ordinal sort to organize the names of files, processes, mutexes, or named pipes.

  • For a comparison that involves a security decision (such as whether a username is valid), you should always perform an ordinal test for equality by calling an overload of the M:System.String.Equals(System.String) method.

System_CAPS_note注意

The culture-sensitive sorting and casing rules used in string comparison depend on the version of the .NET Framework. In the net_v45 running on the win8 operating system, sorting, casing, normalization, and Unicode character information conforms to the Unicode 6.0 standard. On other operating systems, it conforms to the Unicode 5.0 standard.

For more information about word, string, and ordinal sort rules, see the T:System.Globalization.CompareOptions topic. For additional recommendations on when to use each rule, see Best Practices for Using Strings in the .NET Framework.

Ordinarily, you do not call string comparison methods such as M:System.String.Compare(System.String,System.String) directly to determine the sort order of strings. Instead, comparison methods are called by sorting methods such as M:System.Array.Sort(System.Array) or M:System.Collections.Generic.List`1.Sort. The following example performs four different sorting operations (word sort using the current culture, word sort using the invariant culture, ordinal sort, and string sort using the invariant culture) without explicitly calling a string comparison method, although they do specify the type of comparison to use. Note that each type of sort produces a unique ordering of strings in its array.

No code example is currently available or this language may not be supported.
System_CAPS_tip提示

Internally, the.NET Framework uses sort keys to support culturallysensitive string comparison. Each character in a string is given several categories of sort weights, including alphabetic, case, and diacritic. A sort key, represented by the T:System.Globalization.SortKey class, provides a repository of these weights for a particular string. If your app performs a large number of searching or sorting operations on the same set of strings, you can improve its performance by generating and storing sort keys for all the strings that it uses. When a sort or comparison operation is required, you use the sort keys instead of the strings. For more information, see the T:System.Globalization.SortKey class.

If you don't specify a string comparison convention, sorting methods such as M:System.Array.Sort(System.Array) perform a culture-sensitive, case-sensitive sort on strings. The following example illustrates how changing the current culture affects the order of sorted strings in an array. It creates an array of three strings. First, it sets the System.Threading.Thread.CurrentThread.CurrentCulture property to en-US and calls the M:System.Array.Sort(System.Array) method. The resulting sort order is based on sorting conventions for the English (United States) culture. Next, the example sets the System.Threading.Thread.CurrentThread.CurrentCulture property to da-DK and calls the M:System.Array.Sort(System.Array) method again. Notice how the resulting sort order differs from the en-US results because it uses the sorting conventions for Danish (Denmark).

No code example is currently available or this language may not be supported.
System_CAPS_warning警告

If your primary purpose in comparing strings is to determine whether they are equal, you should call the M:System.String.Equals(System.Object) method. Typically, you should use M:System.String.Equals(System.Object) to perform an ordinal comparison. The M:System.String.Compare(System.String,System.String) method is intended primarily to sort strings.

String search methods, such as M:System.String.StartsWith(System.String) and M:System.String.IndexOf(System.Char), also can perform culture-sensitive or ordinal string comparisons. The following example illustrates the differences between ordinal and culture-sensitive comparisons using the M:System.String.IndexOf(System.Char) method. A culture-sensitive search in which the current culture is English (United States) considers the substring "oe" to match the ligature "œ". Because a soft hyphen (U+00AD) is a zero-width character, the search treats the soft hyphen as equivalent to F:System.String.Empty and finds a match at the beginning of the string. An ordinal search, on the other hand, does not find a match in either case.

No code example is currently available or this language may not be supported.

String search methods, such as M:System.String.StartsWith(System.String) and M:System.String.IndexOf(System.Char), also can perform culture-sensitive or ordinal string comparisons to determine whether a character or substring is found in a specified string.

The search methods in the T:System.String class that search for an individual character, such as theM:System.String.IndexOf(System.String) method, or one of a set of characters, such as the M:System.String.IndexOfAny(System.Char[]) method, all perform an ordinal search. To perform a culture-sensitive search for a character, you must call a T:System.Globalization.CompareInfo method such as M:System.Globalization.CompareInfo.IndexOf(System.String,System.Char) or M:System.Globalization.CompareInfo.LastIndexOf(System.String,System.Char). Note that the results of searching for a character using ordinal and culture-sensitive comparison can be very different. For example, a search for a precomposed Unicode character such as the ligature "Æ" (U+00C6) might match any occurrence of its components in the correct sequence, such as "AE" (U+041U+0045), depending on the culture. The following example illustrates the difference between the M:System.String.IndexOf(System.Char) and M:System.Globalization.CompareInfo.IndexOf(System.String,System.Char) methods when searching for an individual character. The ligature "æ" (U+00E6) is found in the string "aerial" when using the conventions of the en-US culture, but not when using the conventions of the da-DK culture or when performing an ordinal comparison.

No code example is currently available or this language may not be supported.

On the other hand, T:System.String class methods that search for a string rather than a character perform a culture-sensitive search if search options are not explicitly specified by a parameter of type T:System.StringComparison. The sole exception is M:System.String.Contains(System.String), which performs an ordinal search.

Use the M:System.String.Compare(System.String,System.String) method to determine the relationship of two strings in the sort order. Typically, this is a culture-sensitive operation. In contrast, call the M:System.String.Equals(System.String) method to test for equality. Because the test for equality usually compares user input with some known string, such as a valid user name, a password, or a file system path, it is typically an ordinal operation.

System_CAPS_warning警告

It is possible to test for equality by calling the M:System.String.Compare(System.String,System.String) method and determining whether the return value is zero. However, this practice is not recommended. To determine whether two strings are equal, you should call one of the overloads of the M:System.String.Equals(System.String) method. The preferred overload to call is either the instance M:System.String.Equals(System.String,System.StringComparison) method or the static M:System.String.Equals(System.String,System.String,System.StringComparison) method, because both methods include a T:System.StringComparison parameter that explicitly specifies the type of comparison.

The following example illustrates the danger of performing a culture-sensitive comparison for equality when an ordinal one should be used instead. In this case, the intent of the code is to prohibit file system access from URLs that begin with "FILE://" or "file://" by performing a case-insensitive comparison of the beginning of a URL with the string "FILE://". However, if a culture-sensitive comparison is performed using the Turkish (Turkey) culture on a URL that begins with "file://", the comparison for equality fails, because the Turkish uppercase equivalent of the lowercase "i" is "İ" instead of "I". As a result, file system access is inadvertently permitted. On the other hand, if an ordinal comparison is performed, the comparison for equality succeeds, and file system access is denied.

No code example is currently available or this language may not be supported.

Some Unicode characters have multiple representations. For example, any of the following code points can represent the letter "ắ":

  • U+1EAF

  • U+0103 U+0301

  • U+0061 U+0306 U+0301

Multiple representations for a single character complicate searching, sorting, matching, and other string operations.

The Unicode standard defines a process called normalization that returns one binary representation of a Unicode character for any of its equivalent binary representations. Normalization can use several algorithms, called normalization forms, that follow different rules. The .NET Framework supports Unicode normalization forms C, D, KC, and KD. When strings have been normalized to the same normalization form, they can be compared by using ordinal comparison.

An ordinal comparison is a binary comparison of the Unicode scalar value of corresponding T:System.Char objects in each string. TheT:System.String class includes a number of methods that can perform an ordinal comparison, including the following:

  • Any overload of the M:System.String.Compare(System.String,System.String), M:System.String.Equals(System.Object), M:System.String.StartsWith(System.String), M:System.String.EndsWith(System.String), M:System.String.IndexOf(System.String),and M:System.String.LastIndexOf(System.String) methods that includes a T:System.StringComparison parameter. The method performs an ordinal comparison if you supply a value of F:System.StringComparison.Ordinal or F:System.StringComparison.OrdinalIgnoreCase for this parameter.

  • The overloads of the M:System.String.CompareOrdinal(System.String,System.String) method.

  • Methods that use ordinal comparison by default, such as M:System.String.Contains(System.String), M:System.String.Replace(System.String,System.String), and M:System.String.Split(System.Char[]).

  • Methods that search for a T:System.Charvalue or for the elements in a T:System.Char arrayin a string instance. Such methods include M:System.String.IndexOf(System.Char) and M:System.String.Split(System.Char[]).

You can determine whether a string is normalized to normalization form C by calling the M:System.String.IsNormalized method, or you can call the M:System.String.IsNormalized(System.Text.NormalizationForm) method to determine whether a string is normalized to a specified normalization form. You can also call the M:System.String.Normalize method to convert a string to normalization form C, or you can call the M:System.String.Normalize(System.Text.NormalizationForm) method to convert a string to a specified normalization form. For step-by-step information about normalizing and comparing strings, see the M:System.String.Normalize and M:System.String.Normalize(System.Text.NormalizationForm) methods.

The following simple example illustrates string normalization. It defines the letter "ố" in three different ways in three different strings, and uses an ordinal comparison for equality to determine that each string differs from the other two strings. It then converts each string to the supported normalization forms, and again performs an ordinal comparison of each string in a specified normalization form. In each case, the second test for equality shows that the strings are equal.

No code example is currently available or this language may not be supported.

For more information about normalization and normalization forms, see T:System.Text.NormalizationForm, as well as Unicode Standard Annex #15: Unicode Normalization Formshttp://unicode.org/reports/tr15/ and the Normalization FAQhttp://www.unicode.org/faq/normalization.html on the unicode.org website.

The T:System.String class provides members for comparing strings, testing strings for equality, finding characters or substrings in a string, modifying a string, extracting substrings from a string, combining strings, formatting values, copying a string, and normalizing a string.

You can compare strings to determine their relative position in the sort order by using the following T:System.Stringmethods:

  • Compare returns an integer that indicates the relationship of one string to a second string in the sort order.

  • CompareOrdinal returns an integer that indicates the relationship of one string to a second string based on a comparison of their code points.

  • CompareTo returns an integer that indicates the relationship of the current string instance to a second string in the sort order. The CompareTo(String) method provides the IComparable and IComparable<'T> implementations for the String class.

You call the M:System.String.Equals(System.String) method to determine whether two strings are equal. The instance M:System.String.Equals(System.String,System.String,System.StringComparison) and the static M:System.String.Equals(System.String,System.StringComparison) overloads let you specify whether the comparison is culture-sensitive or ordinal, and whether case is considered or ignored. Most tests for equality are ordinal, and comparisons for equality that determine access to a system resource (such as a file system object) should always be ordinal.

The T:System.String class includes two kinds of search methods:

  • Methods that return a T:System.Boolean value to indicate whether a particular substring is present in a string instance. These include the M:System.String.Contains(System.String), M:System.String.EndsWith(System.String), and M:System.String.StartsWith(System.String) methods.

  • Methods that indicate the starting position of a substring in a string instance. These include the M:System.String.IndexOf(System.String), M:System.String.IndexOfAny(System.Char[]), M:System.String.LastIndexOf(System.String), and M:System.String.LastIndexOfAny(System.Char[]) methods.

System_CAPS_warning警告

If you want to search a string for a particular pattern rather than a specific substring, you should use regular expressions. For more information, see .NET Framework Regular Expressions.

The T:System.String class includes the following methods that appear to modify the value of a string:

  • Insert inserts a string into the current String instance.

  • PadLeft inserts one or more occurrences of a specified character at the beginning of a string.

  • PadRight inserts one or more occurrences of a specified character at the beginning of a string.

  • Remove deletes a substring from the current String instance.

  • Replace replaces a substring with another substring in the current String instance.

  • ToLower and ToLowerInvariant convert all the characters in a string to lowercase.

  • ToUpper and ToUpperInvariant convert all the characters in a string to uppercase.

  • Trim removes all occurrences of a character from the beginning and end of a string.

  • TrimEnd removes all occurrences of a character from the end of a string.

  • TrimStart removes all occurrences of a character from the beginning of a string.

System_CAPS_important重要

All string modification methods return a new T:System.String object. They do not modify the value of the current instance.

The M:System.String.Split(System.Char[]) method separates a single string into multiple strings. Overloads of the method allow you to specify multiple delimiters, to determine the maximum number of substrings that the method extracts, and to determine whether empty strings (which occur when delimiters are adjacent) are included among the returned strings.

The following T:System.String methods can be used for string concatenation:

  • Concat combines one or more substrings into a single string.

  • Join concatenates one or more substrings into a single element and adds a separator between each substring.

The Overload:System.String.Format method uses the composite formatting feature to replace one or more placeholders in a string with the string representation of some object or value. The Overload:System.String.Format method is often used to do the following:

  • To embed the string representation of a numeric value in a string.

  • To embed the string representation of a date and time value in a string.

  • To embed the string representation of an enumeration value in a string.

  • To embed the string representation of some object that supports the T:System.IFormattable interface in a string.

  • To right-justify or left-justify a substring in a field within a larger string.

For detailed information about formatting operations and examples, see the Overload:System.String.Format overload summary.

You can call the following T:System.String methods to make a copy of a string:

  • Clone returns a reference to an existing String object.

  • Copy creates a copy of an existing string.

  • CopyTo copies a portion of a string to a character array.

In Unicode, a single character can have multiple code points. Normalization converts these equivalent characters into the same binary representation. The M:System.String.Normalize method performs the normalization, and the M:System.String.IsNormalized method determines whether a string is normalized.

For more information and an example, see the Normalization section earlier in this topic.

通用 Windows 平台
自 8 起供應
.NET Framework
自 1.1 起供應
可攜式類別庫
提供支援︰ 可攜式 .NET 平台
Silverlight
自 2.0 起供應
Windows Phone Silverlight
自 7.0 起供應
Windows Phone
自 8.1 起供應

This type is thread safe.

回到頁首
顯示: