本文由机器翻译。若要查看英语原文,请勾选“英语”复选框。 也可将鼠标指针移到文本上,在弹出窗口中显示英语原文。
翻译
英语

String 类

 

将文本表示为 UTF-16 代码单元的序列。

若要浏览此类型的 .NET Framework 源代码,请参阅引用源

命名空间:   System
程序集:  mscorlib(位于 mscorlib.dll)


[<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 位有符号整数数组的指针指示的值。

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)

指示指定的字符串是 null 还是 Empty 字符串。

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.

    目前没有可用的代码示例或不支持该语言。
  • 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.

    目前没有可用的代码示例或不支持该语言。
  • 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.

    目前没有可用的代码示例或不支持该语言。
  • 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.

    目前没有可用的代码示例或不支持该语言。
  • 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.

    目前没有可用的代码示例或不支持该语言。

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.)

    目前没有可用的代码示例或不支持该语言。
  • 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.

    目前没有可用的代码示例或不支持该语言。

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.

目前没有可用的代码示例或不支持该语言。

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.

目前没有可用的代码示例或不支持该语言。

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.

目前没有可用的代码示例或不支持该语言。

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:

    目前没有可用的代码示例或不支持该语言。
  • 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:

    目前没有可用的代码示例或不支持该语言。

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.

目前没有可用的代码示例或不支持该语言。

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.

目前没有可用的代码示例或不支持该语言。

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.

目前没有可用的代码示例或不支持该语言。

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.)

    目前没有可用的代码示例或不支持该语言。
  • 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.

目前没有可用的代码示例或不支持该语言。

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.

目前没有可用的代码示例或不支持该语言。

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.

目前没有可用的代码示例或不支持该语言。

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".

目前没有可用的代码示例或不支持该语言。

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".

目前没有可用的代码示例或不支持该语言。

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.

目前没有可用的代码示例或不支持该语言。
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).

目前没有可用的代码示例或不支持该语言。
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.

目前没有可用的代码示例或不支持该语言。

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.

目前没有可用的代码示例或不支持该语言。

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.

目前没有可用的代码示例或不支持该语言。

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.

目前没有可用的代码示例或不支持该语言。

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.

返回页首
显示: