C#之字符串操作

 注:主要供自己学习记忆使用,有问题希望大家提出。

 

  • 1 确定两个指定的字符串是否具有不同的值。

 

参数: 

a:
要比较的第一个字符串,或 null。

b:
要比较的第二个字符串,或 null。

返回结果:
如果 a 的值与 b 的值不同,则为 true;否则为 false。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static bool operator !=(string a, string b);

  • 2 确定两个指定的字符串是否具有相同的值。

参数:
a:
要比较的第一个字符串,或 null。

b:
要比较的第二个字符串,或 null。

返回结果:
如果 a 的值与 b 的值相同,则为 true;否则为 false。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static bool operator ==(string a, string b);

  • 3获取当前 System.String 对象中的字符数。

返回结果:
当前字符串中字符的数量。
public int Length { get; }

  • 4获取当前 System.String 对象中位于指定位置的 System.Char 对象。

参数:
index:
当前的字符串中的位置。

返回结果:
位于 index 位置的对象。

异常:
System.IndexOutOfRangeException:
index 大于等于该对象的长度或小于零。
public char this[int index] { get; }

  • 5返回对此 System.String 实例的引用。

返回结果:
此 System.String 实例。
public object Clone();

  • 6比较两个指定的 System.String 对象,并返回一个指示二者在排序顺序中的相对位置的整数。


参数:
strA:
要比较的第一个字符串。

strB:
要比较的第二个字符串。

返回结果:
一个 32 位带符号整数,指示两个比较数之间的词法关系。 值 Condition 小于零 strA 小于 strB。 零 strA 等于 strB。
大于零 strA 大于 strB。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static int Compare(string strA, string strB);

  • 7比较两个指定的 System.String 对象(其中忽略或考虑其大小写),并返回一个整数,指示二者在排序顺序中的相对位置。


参数:
strA:
要比较的第一个字符串。

strB:
要比较的第二个字符串。

ignoreCase:
要在比较过程中忽略大小写,则为 true;否则为 false。

返回结果:
一个 32 位带符号整数,指示两个比较数之间的词法关系。 值 Condition 小于零 strA 小于 strB。 零 strA 等于 strB。
大于零 strA 大于 strB。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static int Compare(string strA, string strB, bool ignoreCase);

  • 8 使用指定的规则比较两个指定的 System.String 对象,并返回一个整数,指示二者在排序顺序中的相对位置。


参数:
strA:
要比较的第一个字符串。

strB:
要比较的第二个字符串。

comparisonType:
一个枚举值,用于指定比较中要使用的规则。

返回结果:
一个 32 位带符号整数,指示两个比较数之间的词法关系。 值 Condition 小于零 strA 小于 strB。 零 strA 等于 strB。
大于零 strA 大于 strB。

异常:
System.ArgumentException:
comparisonType 不是一个 System.StringComparison 值。

System.NotSupportedException:
不支持 System.StringComparison。
[SecuritySafeCritical]
public static int Compare(string strA, string strB, StringComparison comparisonType);

  • 9 比较两个指定的 System.String 对象(其中忽略或考虑其大小写,并使用区域性特定的信息干预比较),并返回一个整数,指示二者在排序顺序中的相对位置。


参数:
strA:
要比较的第一个字符串。

strB:
要比较的第二个字符串。

ignoreCase:
要在比较过程中忽略大小写,则为 true;否则为 false。

culture:
一个对象,提供区域性特定的比较信息。

返回结果:
一个 32 位带符号整数,指示两个比较数之间的词法关系。 值 Condition 小于零 strA 小于 strB。 零 strA 等于 strB。
大于零 strA 大于 strB。

异常:
System.ArgumentNullException:
culture 为 null。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static int Compare(string strA, string strB, bool ignoreCase, CultureInfo culture);

10    对两个指定的 System.String 对象进行比较,使用指定的比较选项和区域性特定的信息来影响比较,并返回一个整数,该整数指示这两个字符串在排序顺序中的关系。

参数:
strA:
要比较的第一个字符串。

strB:
要比较的第二个字符串。

culture:
提供区域性特定的比较信息的区域性。

options:
要在执行比较时使用的选项(如忽略大小写或符号)。

返回结果:
一个 32 位带符号整数,该整数指示 strA 与 strB 之间的词法关系,如下表所示 值 Condition 小于零 strA 小于 strB。
零 strA 等于 strB。 大于零 strA 大于 strB。

异常:
System.ArgumentException:
options 不是一个 System.Globalization.CompareOptions 值。

System.ArgumentNullException:
culture 为 null。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static int Compare(string strA, string strB, CultureInfo culture, CompareOptions options);

11对两个指定的 System.String 对象的子字符串进行比较,并返回一个指示二者在排序顺序中的相对位置的整数。

参数:
strA:
要在比较中使用的第一个字符串。

indexA:
strA 中子字符串的位置。

strB:
要在比较中使用的第二个字符串。

indexB:
strB 中子字符串的位置。

length:
要比较的子字符串中字符的最大数量。

返回结果:
一个 32 位有符号整数,指示两个比较数之间的词法关系。 值 Condition 小于零 strA 中的子字符串小于 strB 中的子字符串。 零
子字符串相等,或者 length 为零。 大于零 strA 中的子字符串大于 strB 中的子字符串。

异常:
System.ArgumentOutOfRangeException:
indexA 大于 strA.System.String.Length。 - 或 - indexB 大于 strB.System.String.Length。
- 或 - indexA、indexB 或 length 为负。 - 或 - indexA 或 indexB 为 null,而 length 大于零。
public static int Compare(string strA, int indexA, string strB, int indexB, int length);

12比较两个指定的 System.String 对象的子字符串(忽略或考虑其大小写),并返回一个整数,指示二者在排序顺序中的相对位置。

参数:
strA:
要在比较中使用的第一个字符串。

indexA:
strA 中子字符串的位置。

strB:
要在比较中使用的第二个字符串。

indexB:
strB 中子字符串的位置。

length:
要比较的子字符串中字符的最大数量。

ignoreCase:
要在比较过程中忽略大小写,则为 true;否则为 false。

返回结果:
一个 32 位带符号整数,指示两个比较数之间的词法关系。 值 Condition 小于零 strA 中的子字符串小于 strB 中的子字符串。 零
子字符串相等,或者 length 为零。 大于零 strA 中的子字符串大于 strB 中的子字符串。

异常:
System.ArgumentOutOfRangeException:
indexA 大于 strA.System.String.Length。 - 或 - indexB 大于 strB.System.String.Length。
- 或 - indexA、indexB 或 length 为负。 - 或 - indexA 或 indexB 为 null,而 length 大于零。
public static int Compare(string strA, int indexA, string strB, int indexB, int length, bool ignoreCase);

13 使用指定的规则比较两个指定的 System.String 对象的子字符串,并返回一个整数,指示二者在排序顺序中的相对位置。

参数:
strA:
要在比较中使用的第一个字符串。

indexA:
strA 中子字符串的位置。

strB:
要在比较中使用的第二个字符串。

indexB:
strB 中子字符串的位置。

length:
要比较的子字符串中字符的最大数量。

comparisonType:
一个枚举值,用于指定比较中要使用的规则。

返回结果:
一个 32 位带符号整数,指示两个比较数之间的词法关系。 值 Condition 小于零 strA 参数中的子字符串小于 strB 参数中的子字符串。
零 子字符串相等,或者 length 参数为零。 大于零 strA 中的子字符串大于 strB 中的子字符串。

异常:
System.ArgumentOutOfRangeException:
indexA 大于 strA.System.String.Length。 - 或 - indexB 大于 strB.System.String.Length。
- 或 - indexA、indexB 或 length 为负。 - 或 - indexA 或 indexB 为 null,而 length 大于零。

System.ArgumentException:
comparisonType 不是一个 System.StringComparison 值。
[SecuritySafeCritical]
public static int Compare(string strA, int indexA, string strB, int indexB, int length, StringComparison comparisonType);

14 比较两个指定的 System.String 对象的子字符串(其中忽略或考虑其大小写,并使用区域性特定的信息干预比较),并返回一个整数,指示二者在排序顺序中的相对位置。

参数:
strA:
要在比较中使用的第一个字符串。

indexA:
strA 中子字符串的位置。

strB:
要在比较中使用的第二个字符串。

indexB:
strB 中子字符串的位置。

length:
要比较的子字符串中字符的最大数量。

ignoreCase:
要在比较过程中忽略大小写,则为 true;否则为 false。

culture:
一个对象,提供区域性特定的比较信息。

返回结果:
一个整数,指示两个比较字之间的词法关系。 值 Condition 小于零 strA 中的子字符串小于 strB 中的子字符串。 零 子字符串相等,或者
length 为零。 大于零 strA 中的子字符串大于 strB 中的子字符串。

异常:
System.ArgumentOutOfRangeException:
indexA 大于 strA.System.String.Length。 - 或 - indexB 大于 strB.System.String.Length。
- 或 - indexA、indexB 或 length 为负。 - 或 - strA 或 strB 为 null,而 length 大于零。

System.ArgumentNullException:
culture 为 null。
public static int Compare(string strA, int indexA, string strB, int indexB, int length, bool ignoreCase, CultureInfo culture);

15对两个指定 System.String 对象的子字符串进行比较,使用指定的比较选项和区域性特定的信息来影响比较,并返回一个整数,该整数指示这两个子字符串在排序顺序中的关系。

参数:
strA:
要在比较中使用的第一个字符串。

indexA:
strA 中子字符串开始的位置。

strB:
要在比较中使用的第二个字符串。

indexB:
strB 中子字符串开始的位置。

length:
要比较的子字符串中字符的最大数量。

culture:
一个对象,提供区域性特定的比较信息。

options:
要在执行比较时使用的选项(如忽略大小写或符号)。

返回结果:
一个整数,该整数用于指示两个子字符串之间的词法关系,如下表所示。 值 Condition 小于零 strA 中的子字符串小于 strB 中的子字符串。
零 两个子字符串相等或者 length 为零。 大于零 strA 中的子字符串大于 strB 中的子字符串。

异常:
System.ArgumentException:
options 不是一个 System.Globalization.CompareOptions 值。

System.ArgumentOutOfRangeException:
indexA 大于 strA.Length。 - 或 - indexB 大于 strB.Length。 - 或 - indexA、indexB 或
length 为负。 - 或 - strA 或 strB 为 null,而 length 大于零。

System.ArgumentNullException:
culture 为 null。
public static int Compare(string strA, int indexA, string strB, int indexB, int length, CultureInfo culture, CompareOptions options);

16 通过计算每个字符串中相应 System.Char 对象的数值来比较两个指定的 System.String 对象。

参数:
strA:
要比较的第一个字符串。

strB:
要比较的第二个字符串。

返回结果:
一个整数,指示两个比较字之间的词法关系。 值 Condition 小于零 strA 小于 strB。 零 strA 与 strB 相等。 大于零
strA 大于 strB。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static int CompareOrdinal(string strA, string strB);

摘要:
通过计算两个指定的 System.String 对象的每个子字符串中相应 System.Char 对象的数值比较子字符串。

参数:
strA:
要在比较中使用的第一个字符串。

indexA:
strA 中子字符串的起始索引。

strB:
要在比较中使用的第二个字符串。

indexB:
strB 中子字符串的起始索引。

length:
要比较的子字符串中字符的最大数量。

返回结果:
一个 32 位带符号整数,指示两个比较数之间的词法关系。 值 Condition 小于零 strA 中的子字符串小于 strB 中的子字符串。 零
子字符串相等,或者 length 为零。 大于零 strA 中的子字符串大于 strB 中的子字符串。

异常:
System.ArgumentOutOfRangeException:
strA 不为 null,且 indexA 大于 strA。System.String.Length。 - 或 - strB 不为 null,且
indexB 大于 strB。System.String.Length。 - 或 - indexA、indexB 或 length 为负。
[SecuritySafeCritical]
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static int CompareOrdinal(string strA, int indexA, string strB, int indexB, int length);

17将此实例与指定的 System.Object 进行比较,并指示此实例在排序顺序中是位于指定的 System.Object 之前、之后还是与其出现在同一位置。

参数:
value:
一个对象,其计算结果为 System.String。

返回结果:
一个 32 位有符号整数,该整数指示此实例在排序顺序中是位于 value 参数之前、之后还是与其出现在同一位置。 值 Condition 小于零
此实例位于 value 之前。 零 此实例在排序顺序中的位置与 value 相同。 大于零 此实例位于 value 之后。 - 或 - value
为 null。

异常:
System.ArgumentException:
value 不是 System.String。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public int CompareTo(object value);

18 将此实例与指定的 System.String 对象进行比较,并指示此实例在排序顺序中是位于指定的 System.String 之前、之后还是与其出现在同一位置。

参数:
strB:
要与此实例进行比较的字符串。

返回结果:
一个 32 位有符号整数,该整数指示此实例在排序顺序中是位于 value 参数之前、之后还是与其出现在同一位置。 值 Condition 小于零
此实例位于 strB 之前。 零 此实例在排序顺序中的位置与 strB 相同。 大于零 此实例位于 strB 之后。 - 或 - strB 为 null。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public int CompareTo(string strB);

19 串联类型为 System.String 的 System.Collections.Generic.IEnumerable<T> 构造集合的成员。

参数:
values:
一个集合对象,该对象实现 System.Collections.Generic.IEnumerable<T>,且其泛型类型参数为 System.String。

返回结果:
values 中的串联字符串。

异常:
System.ArgumentNullException:
values 为 null。
[ComVisible(false)]
public static string Concat(IEnumerable<string> values);

20 串联 System.Collections.Generic.IEnumerable<T> 实现的成员。

参数:
values:
一个实现 System.Collections.Generic.IEnumerable<T> 接口的集合对象。

类型参数:
T:
values 成员的类型。

返回结果:
values 中的串联成员。

异常:
System.ArgumentNullException:
values 为 null。
[ComVisible(false)]
public static string Concat<T>(IEnumerable<T> values);

21创建指定对象的字符串表示形式。

参数:
arg0:
要表示的对象,或 null。

返回结果:
arg0 或 System.String.Empty 值的字符串表示形式,如果为 arg0,则为 null。
public static string Concat(object arg0);

22 连接指定 System.Object 数组中的元素的字符串表示形式。

参数:
args:
一个对象数组,其中包含要连接的元素。

返回结果:
args 中元素的值经过连接的字符串表示形式。

异常:
System.ArgumentNullException:
args 为 null。

System.OutOfMemoryException:
内存不足。
public static string Concat(params object[] args);

23连接指定的 System.String 数组的元素。

参数:
values:
字符串实例的数组。

返回结果:
values 的连接元素。

异常:
System.ArgumentNullException:
values 为 null。

System.OutOfMemoryException:
内存不足。
public static string Concat(params string[] values);

24 连接两个指定对象的字符串表示形式。

参数:
arg0:
要连接的第一个对象。

arg1:
要连接的第二个对象。

返回结果:
arg0 和 arg1 的值经过连接的字符串表示形式。
public static string Concat(object arg0, object arg1);

25连接 System.String 的两个指定实例。

参数:
str0:
要连接的第一个字符串。

str1:
要连接的第二个字符串。

返回结果:
str0 和 str1 的连接。
[SecuritySafeCritical]
public static string Concat(string str0, string str1);

26 连接三个指定对象的字符串表示形式。

参数:
arg0:
要连接的第一个对象。

arg1:
要连接的第二个对象。

arg2:
要连接的第三个对象。

返回结果:
arg0、arg1 和 arg2 的值经过连接的字符串表示形式。
public static string Concat(object arg0, object arg1, object arg2);

27 连接 System.String 的三个指定实例。

参数:
str0:
要连接的第一个字符串。

str1:
要连接的第二个字符串。

str2:
要连接的第三个字符串。

返回结果:
str0、str1 和 str2 的连接。
[SecuritySafeCritical]
public static string Concat(string str0, string str1, string str2);

28将四个指定对象的字符串表示形式与可选变量长度参数列表中指定的任何对象串联起来。

参数:
arg0:
要连接的第一个对象。

arg1:
要连接的第二个对象。

arg2:
要连接的第三个对象。

arg3:
要连接的第四个对象。

返回结果:
参数列表中的每个值的连接字符串表示形式。
[CLSCompliant(false)]
public static string Concat(object arg0, object arg1, object arg2, object arg3);

29连接 System.String 的四个指定实例。

参数:
str0:
要连接的第一个字符串。

str1:
要连接的第二个字符串。

str2:
要连接的第三个字符串。

str3:
要连接的第四个字符串。

返回结果:
str0、str1、str2 和 str3 的连接。
[SecuritySafeCritical]
public static string Concat(string str0, string str1, string str2, string str3);

30返回一个值,该值指示指定的 System.String 对象是否出现在此字符串中。

参数:
value:
要搜寻的字符串。

返回结果:
如果 value 参数出现在此字符串中,或者 value 为空字符串 (""),则为 true;否则为 false。

异常:
System.ArgumentNullException:
value 为 null。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public bool Contains(string value);

31 创建一个与指定的 System.String 具有相同值的 System.String 的新实例。

参数:
str:
要复制的字符串。

返回结果:
值与 str 相同的新字符串。

异常:
System.ArgumentNullException:
str 为 null。
[SecuritySafeCritical]
public static string Copy(string str);

32将指定数目的字符从此实例中的指定位置复制到 Unicode 字符数组中的指定位置。

参数:
sourceIndex:
要复制的此实例中第一个字符的索引。

destination:
此实例中的字符所复制到的 Unicode 字符数组。

destinationIndex:
destination 中的索引,在此处开始复制操作。

count:
此实例中要复制到 destination 的字符数。

异常:
System.ArgumentNullException:
destination 为 null。

System.ArgumentOutOfRangeException:
sourceIndex、destinationIndex 或 count 为负 - 或 - count 大于从 startIndex 到此实例末尾的子字符串的长度
- 或 - count 大于从 destinationIndex 到 destination 末尾的子数组的长度
[SecuritySafeCritical]
public void CopyTo(int sourceIndex, char[] destination, int destinationIndex, int count);

33确定此字符串实例的结尾是否与指定的字符串匹配。

参数:
value:
要与此实例末尾的子字符串进行比较的字符串。

返回结果:
如果 value 与此实例的末尾匹配,则为 true;否则为 false。

异常:
System.ArgumentNullException:
value 为 null。
public bool EndsWith(string value);

34确定使用指定的比较选项进行比较时此字符串实例的结尾是否与指定的字符串匹配。

参数:
value:
要与此实例末尾的子字符串进行比较的字符串。

comparisonType:
枚举值之一,用于确定如何比较此字符串与 value。

返回结果:
如果此字符串的末尾与 value 参数匹配,则为 true;否则为 false。

异常:
System.ArgumentNullException:
value 为 null。

System.ArgumentException:
comparisonType 不是一个 System.StringComparison 值。
[ComVisible(false)]
[SecuritySafeCritical]
public bool EndsWith(string value, StringComparison comparisonType);

35确定在使用指定的区域性进行比较时此字符串实例的结尾是否与指定的字符串匹配。

参数:
value:
要与此实例末尾的子字符串进行比较的字符串。

ignoreCase:
要在比较过程中忽略大小写,则为 true;否则为 false。

culture:
确定如何对此实例与 value 进行比较的区域性信息。 如果 culture 为 null,则使用当前区域性。

返回结果:
如果此字符串的末尾与 value 参数匹配,则为 true;否则为 false。

异常:
System.ArgumentNullException:
value 为 null。
public bool EndsWith(string value, bool ignoreCase, CultureInfo culture);

36 确定此实例是否与指定的对象(也必须是 System.String 对象)具有相同的值。

参数:
obj:
要与此实例进行比较的字符串。

返回结果:
如果 obj 为 System.String 并且它的值与此实例相同,则为 true;否则为 false。
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
public override bool Equals(object obj);

37确定此实例是否与另一个指定的 System.String 对象具有相同的值。

参数:
value:
要与此实例进行比较的字符串。

返回结果:
如果 value 参数的值与此实例相同,则为 true;否则为 false。
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public bool Equals(string value);

38 确定两个指定的 System.String 对象是否具有相同的值。

参数:
a:
要比较的第一个字符串,或 null。

b:
要比较的第二个字符串,或 null。

返回结果:
如果 a 的值与 b 的值相同,则为 true;否则为 false。 如果 a 和 b 均为 null,该方法返回 true。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static bool Equals(string a, string b);

39 确定此字符串是否与指定的 System.String 对象具有相同的值。 参数指定区域性、大小写以及比较所用的排序规则。

参数:
value:
要与此实例进行比较的字符串。

comparisonType:
枚举值之一,用于指定将如何比较字符串。

返回结果:
如果 value 参数的值与此字符串相同,则为 true;否则为 false。

异常:
System.ArgumentException:
comparisonType 不是一个 System.StringComparison 值。
[SecuritySafeCritical]
public bool Equals(string value, StringComparison comparisonType);

40确定两个指定的 System.String 对象是否具有相同的值。 参数指定区域性、大小写以及比较所用的排序规则。

参数:
a:
要比较的第一个字符串,或 null。

b:
要比较的第二个字符串,或 null。

comparisonType:
枚举值之一,用于指定比较的规则。

返回结果:
如果 a 参数的值等于 b 参数的值,则为 true;否则为 false。

异常:
System.ArgumentException:
comparisonType 不是一个 System.StringComparison 值。
[SecuritySafeCritical]
public static bool Equals(string a, string b, StringComparison comparisonType);

41 将指定字符串中的一个或多个格式项替换为指定对象的字符串表示形式。

参数:
format:
符合格式字符串(参见“备注”)。

arg0:
要设置格式的对象。

返回结果:
format 的副本,其中的任何格式项均替换为 arg0 的字符串表示形式。

异常:
System.ArgumentNullException:
format 为 null。

System.FormatException:
format 中的格式项无效。 - 或 - 格式项的索引不零。
public static string Format(string format, object arg0);

42 将指定字符串中的格式项替换为指定数组中相应对象的字符串表示形式。

参数:
format:
符合格式字符串(参见“备注”)。

args:
一个对象数组,其中包含零个或多个要设置格式的对象。

返回结果:
format 的一个副本,其中格式项已替换为 args 中相应对象的字符串表示形式。

异常:
System.ArgumentNullException:
format 或 args 为 null。

System.FormatException:
format 无效。 - 或 - 格式项的索引小于零或大于等于 args 数组的长度。
public static string Format(string format, params object[] args);

43 将指定字符串中的格式项替换为指定数组中相应对象的字符串表示形式。 指定的参数提供区域性特定的格式设置信息。

参数:
provider:
一个提供区域性特定的格式设置信息的对象。

format:
符合格式字符串(参见“备注”)。

args:
一个对象数组,其中包含零个或多个要设置格式的对象。

返回结果:
format 的一个副本,其中格式项已替换为 args 中相应对象的字符串表示形式。

异常:
System.ArgumentNullException:
format 或 args 为 null。

System.FormatException:
format 无效。 - 或 - 格式项的索引小于零或大于等于 args 数组的长度。
public static string Format(IFormatProvider provider, string format, params object[] args);

44 将指定字符串中的格式项替换为两个指定对象的字符串表示形式。

参数:
format:
符合格式字符串(参见“备注”)。

arg0:
要设置格式的第一个对象。

arg1:
要设置格式的第二个对象。

返回结果:
format 的副本,其中的格式项替换为 arg0 和 arg1 的字符串表示形式。

异常:
System.ArgumentNullException:
format 为 null。

System.FormatException:
format 无效。 - 或 - 格式项的索引不为零和一。
public static string Format(string format, object arg0, object arg1);

45 将指定字符串中的格式项替换为三个指定对象的字符串表示形式。

参数:
format:
符合格式字符串(参见“备注”)。

arg0:
要设置格式的第一个对象。

arg1:
要设置格式的第二个对象。

arg2:
要设置格式的第三个对象。

返回结果:
format 的副本,其中的格式项已替换为 arg0、arg1 和 arg2 的字符串表示形式。

异常:
System.ArgumentNullException:
format 为 null。

System.FormatException:
format 无效。 - 或 - 格式项的索引小于零或大于二。
public static string Format(string format, object arg0, object arg1, object arg2);

46检索一个可以循环访问此字符串中的每个字符的对象。

返回结果:
枚举器对象。
public CharEnumerator GetEnumerator();

47 返回该字符串的哈希代码。

返回结果:
32 位有符号整数哈希代码。
[ReliabilityContract(Consistency.WillNotCorruptState, Cer.MayFail)]
[SecuritySafeCritical]
public override int GetHashCode();

48 返回类 System.String 的 System.TypeCode。

返回结果:
枚举常数 System.TypeCode.String。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public TypeCode GetTypeCode();

49报告指定 Unicode 字符在此字符串中的第一个匹配项的从零开始的索引。

参数:
value:
要查找的 Unicode 字符。

返回结果:
如果找到该字符,则为 value 的从零开始的索引位置;如果未找到,则为 -1。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public int IndexOf(char value);

50报告指定字符串在此实例中的第一个匹配项的从零开始的索引。

参数:
value:
要搜寻的字符串。

返回结果:
如果找到该字符串,则为 value 的从零开始的索引位置;如果未找到该字符串,则为 -1。 如果 value 为 System.String.Empty,则返回值为
0。

异常:
System.ArgumentNullException:
value 为 null。
public int IndexOf(string value);

51报告指定 Unicode 字符在此字符串中的第一个匹配项的从零开始的索引。 该搜索从指定字符位置开始。

参数:
value:
要查找的 Unicode 字符。

startIndex:
搜索起始位置。

返回结果:
如果找到该字符,则为 value 的从零开始的索引位置;如果未找到,则为 -1。

异常:
System.ArgumentOutOfRangeException:
startIndex 小于零或大于字符串的长度。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public int IndexOf(char value, int startIndex);

52 报告指定字符串在此实例中的第一个匹配项的从零开始的索引。 该搜索从指定字符位置开始。

参数:
value:
要搜寻的字符串。

startIndex:
搜索起始位置。

返回结果:
如果找到该字符串,则为 value 的从零开始的索引位置;如果未找到该字符串,则为 -1。 如果 value 为 System.String.Empty,则返回值为
startIndex。

异常:
System.ArgumentNullException:
value 为 null。

System.ArgumentOutOfRangeException:
startIndex 小于零或大于此字符串的长度。
public int IndexOf(string value, int startIndex);

53报告指定的字符串在当前 System.String 对象中的第一个匹配项的从零开始的索引。 一个参数指定要用于指定字符串的搜索类型

参数:
value:
要搜寻的字符串。

comparisonType:
指定搜索规则的枚举值之一。

返回结果:
如果找到该字符串,则为 value 参数的索引位置;如果未找到该字符串,则为 -1。 如果 value 为 System.String.Empty,则返回值为
0。

异常:
System.ArgumentNullException:
value 为 null。

System.ArgumentException:
comparisonType 不是有效的 System.StringComparison 值。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public int IndexOf(string value, StringComparison comparisonType);

54报告指定字符在此实例中的第一个匹配项的从零开始的索引。 搜索从指定字符位置开始,并检查指定数量的字符位置。

参数:
value:
要查找的 Unicode 字符。

startIndex:
搜索起始位置。

count:
要检查的字符位置数。

返回结果:
如果找到该字符,则为 value 的从零开始的索引位置;如果未找到,则为 -1。

异常:
System.ArgumentOutOfRangeException:
count 或 startIndex 为负。 - 或 - startIndex 大于此字符串的长度。 - 或 - count 大于此字符串的长度减去
startIndex。
[SecuritySafeCritical]
public int IndexOf(char value, int startIndex, int count);

55报告指定字符串在此实例中的第一个匹配项的从零开始的索引。 搜索从指定字符位置开始,并检查指定数量的字符位置。

参数:
value:
要搜寻的字符串。

startIndex:
搜索起始位置。

count:
要检查的字符位置数。

返回结果:
如果找到该字符串,则为 value 的从零开始的索引位置;如果未找到该字符串,则为 -1。 如果 value 为 System.String.Empty,则返回值为
startIndex。

异常:
System.ArgumentNullException:
value 为 null。

System.ArgumentOutOfRangeException:
count 或 startIndex 为负。 - 或 - startIndex 大于此字符串的长度。 - 或 - count 大于此字符串的长度减去
startIndex。
public int IndexOf(string value, int startIndex, int count);

56 报告指定的字符串在当前 System.String 对象中的第一个匹配项的从零开始的索引。 参数指定当前字符串中的起始搜索位置以及用于指定字符串的搜索类型。

参数:
value:
要搜寻的字符串。

startIndex:
搜索起始位置。

comparisonType:
指定搜索规则的枚举值之一。

返回结果:
如果找到该字符串,则为 value 参数的从零开始的索引位置;如果未找到该字符串,则为 -1。 如果 value 为 System.String.Empty,则返回值为
startIndex。

异常:
System.ArgumentNullException:
value 为 null。

System.ArgumentOutOfRangeException:
startIndex 小于零或大于此字符串的长度。

System.ArgumentException:
comparisonType 不是有效的 System.StringComparison 值。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public int IndexOf(string value, int startIndex, StringComparison comparisonType);

57报告指定的字符串在当前 System.String 对象中的第一个匹配项的从零开始的索引。 参数指定当前字符串中的起始搜索位置、要搜索的当前字符串中的字符数量,以及要用于指定字符串的搜索类型。

参数:
value:
要搜寻的字符串。

startIndex:
搜索起始位置。

count:
要检查的字符位置数。

comparisonType:
指定搜索规则的枚举值之一。

返回结果:
如果找到该字符串,则为 value 参数的从零开始的索引位置;如果未找到该字符串,则为 -1。 如果 value 为 System.String.Empty,则返回值为
startIndex。

异常:
System.ArgumentNullException:
value 为 null。

System.ArgumentOutOfRangeException:
count 或 startIndex 为负。 - 或 - startIndex 大于此实例的长度。 - 或 - count 大于此字符串的长度减去
startIndex。

System.ArgumentException:
comparisonType 不是有效的 System.StringComparison 值。
[SecuritySafeCritical]
public int IndexOf(string value, int startIndex, int count, StringComparison comparisonType);

摘要:
报告指定 Unicode 字符数组中的任意字符在此实例中第一个匹配项的从零开始的索引。

参数:
anyOf:
Unicode 字符数组,包含一个或多个要查找的字符。

返回结果:
在此实例中第一次找到 anyOf 中的任意字符的索引位置(从零开始);如果未找到 anyOf 中的字符,则为 -1。

异常:
System.ArgumentNullException:
anyOf 为 null。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public int IndexOfAny(char[] anyOf);

摘要:
报告指定 Unicode 字符数组中的任意字符在此实例中第一个匹配项的从零开始的索引。 该搜索从指定字符位置开始。

参数:
anyOf:
Unicode 字符数组,包含一个或多个要查找的字符。

startIndex:
搜索起始位置。

返回结果:
在此实例中第一次找到 anyOf 中的任意字符的索引位置(从零开始);如果未找到 anyOf 中的字符,则为 -1。

异常:
System.ArgumentNullException:
anyOf 为 null。

System.ArgumentOutOfRangeException:
startIndex 为负数。 - 或 - startIndex 大于此实例中的字符数。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public int IndexOfAny(char[] anyOf, int startIndex);

摘要:
报告指定 Unicode 字符数组中的任意字符在此实例中第一个匹配项的从零开始的索引。 搜索从指定字符位置开始,并检查指定数量的字符位置。

参数:
anyOf:
Unicode 字符数组,包含一个或多个要查找的字符。

startIndex:
搜索起始位置。

count:
要检查的字符位置数。

返回结果:
在此实例中第一次找到 anyOf 中的任意字符的索引位置(从零开始);如果未找到 anyOf 中的字符,则为 -1。

异常:
System.ArgumentNullException:
anyOf 为 null。

System.ArgumentOutOfRangeException:
count 或 startIndex 为负。 - 或 - count+startIndex 大于此实例中的字符数。
[SecuritySafeCritical]
public int IndexOfAny(char[] anyOf, int startIndex, int count);

摘要:
返回指定字符串在这种情况下插入在指定索引位置的新字符串。

参数:
startIndex:
插入的从零开始的索引位置。

value:
要插入的字符串。

返回结果:
与此实例等效的一个新字符串,但在该字符串的 startIndex 位置处插入了 value。

异常:
System.ArgumentNullException:
value 为 null。

System.ArgumentOutOfRangeException:
startIndex 为负,或大于此实例的长度。
[SecuritySafeCritical]
public string Insert(int startIndex, string value);

摘要:
检索系统对指定 System.String 的引用。

参数:
str:
要在暂存池中搜索的字符串。

返回结果:
如果暂存了 str,则返回系统对其的引用;否则返回对值为 str 的字符串的新引用。

异常:
System.ArgumentNullException:
str 为 null。
[SecuritySafeCritical]
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static string Intern(string str);

摘要:
检索对指定 System.String 的引用。

参数:
str:
要在暂存池中搜索的字符串。

返回结果:
如果 str 在公共语言运行时的暂存池中,则返回对它的引用;否则返回 null。

异常:
System.ArgumentNullException:
str 为 null。
[SecuritySafeCritical]
public static string IsInterned(string str);

摘要:
指示此字符串是否符合 Unicode 范式 C。

返回结果:
如果此字符串符合范式 C,则为 true;否则为 false。

异常:
System.ArgumentException:
当前实例包含无效的 Unicode 字符。
public bool IsNormalized();

摘要:
指示此字符串是否符合指定的 Unicode 范式。

参数:
normalizationForm:
一个 Unicode 范式。

返回结果:
如果此字符串符合由 normalizationForm 参数指定的范式,则为 true;否则为 false。

异常:
System.ArgumentException:
当前实例包含无效的 Unicode 字符。
[SecuritySafeCritical]
public bool IsNormalized(NormalizationForm normalizationForm);

摘要:
指示指定的字符串是 null 还是 System.String.Empty 字符串。

参数:
value:
要测试的字符串。

返回结果:
如果 value 参数为 null 或空字符串 (""),则为 true;否则为 false。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public static bool IsNullOrEmpty(string value);

摘要:
指示指定的字符串是 null、空还是仅由空白字符组成。

参数:
value:
要测试的字符串。

返回结果:
如果 value 参数为 null 或 System.String.Empty,或者如果 value 仅由空白字符组成,则为 true。
public static bool IsNullOrWhiteSpace(string value);

摘要:
串联类型为 System.String 的 System.Collections.Generic.IEnumerable<T> 构造集合的成员,其中在每个成员之间使用指定的分隔符。

参数:
separator:
要用作分隔符的字符串。

values:
一个包含要串联的字符串的集合。

返回结果:
一个由 values 的成员组成的字符串,这些成员以 separator 字符串分隔。 如果 values 无元素,则方法返回 System.String.Empty。

异常:
System.ArgumentNullException:
values 为 null。
[ComVisible(false)]
public static string Join(string separator, IEnumerable<string> values);

摘要:
串联集合的成员,其中在每个成员之间使用指定的分隔符。

参数:
separator:
要用作分隔符的字符串。

values:
一个包含要串联的对象的集合。

类型参数:
T:
values 成员的类型。

返回结果:
一个由 values 的成员组成的字符串,这些成员以 separator 字符串分隔。 如果 values 无元素,则方法返回 System.String.Empty。

异常:
System.ArgumentNullException:
values 为 null。
[ComVisible(false)]
public static string Join<T>(string separator, IEnumerable<T> values);

摘要:
串联对象数组的各个元素,其中在每个元素之间使用指定的分隔符。

参数:
separator:
要用作分隔符的字符串。

values:
一个数组,其中包含要连接的元素。

返回结果:
一个由 values 的元素组成的字符串,这些元素以 separator 字符串分隔。 如果 values 为空数组,则 System.String.Empty
方法将返回 。

异常:
System.ArgumentNullException:
values 为 null。
[ComVisible(false)]
public static string Join(string separator, params object[] values);

摘要:
串联字符串数组的所有元素,其中在每个元素之间使用指定的分隔符。

参数:
separator:
要用作分隔符的字符串。

value:
一个数组,其中包含要连接的元素。

返回结果:
一个由 value 中的元素组成的字符串,这些元素以 separator 字符串分隔。 如果 value 为空数组,则 System.String.Empty
方法将返回 。

异常:
System.ArgumentNullException:
value 为 null。
public static string Join(string separator, params string[] value);

摘要:
串联字符串数组的指定元素,其中在每个元素之间使用指定的分隔符。

参数:
separator:
要用作分隔符的字符串。

value:
一个数组,其中包含要连接的元素。

startIndex:
value 中要使用的第一个元素。

count:
要使用的 value 的元素数。

返回结果:
由 value 中的字符串组成的字符串,这些字符串以 separator 字符串分隔。 - 或 - 如果 count 为零,value 没有元素,或
separator 以及 value 的全部元素均为 System.String.Empty,则为 System.String.Empty。

异常:
System.ArgumentNullException:
value 为 null。

System.ArgumentOutOfRangeException:
startIndex 或 count 小于 0。 - 或 - startIndex 加上 count 大于 value 中的元素数。

System.OutOfMemoryException:
内存不足。
[SecuritySafeCritical]
public static string Join(string separator, string[] value, int startIndex, int count);

摘要:
报告指定 Unicode 字符在此实例中的最后一个匹配项的从零开始的索引位置。

参数:
value:
要查找的 Unicode 字符。

返回结果:
如果找到该字符,则为 value 的从零开始的索引位置;如果未找到,则为 -1。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public int LastIndexOf(char value);

摘要:
报告指定字符串在此实例中的最后一个匹配项的从零开始的索引位置。

参数:
value:
要搜寻的字符串。

返回结果:
如果找到该字符串,则为 value 的从零开始的索引位置;如果未找到该字符串,则为 -1。 如果 value 为 System.String.Empty,则返回值为此实例中的最后一个索引位置。

异常:
System.ArgumentNullException:
value 为 null。
public int LastIndexOf(string value);

摘要:
报告指定 Unicode 字符在此实例中的最后一个匹配项的从零开始的索引位置。 在指定的字符位置开始和在向后的右边该字符串的开头处理的搜索。

参数:
value:
要查找的 Unicode 字符。

startIndex:
搜索的起始位置。 从 startIndex 此实例的开头开始搜索。

返回结果:
如果找到该字符,则为 value 的从零开始的索引位置;如果未找到,则为 -1。或者如果当前实例等于 System.String.Empty 则也为
-1。

异常:
System.ArgumentOutOfRangeException:
当前实例不等于 System.String.Empty,而且 startIndex 小于零,或者大于或等于此实例的长度。
public int LastIndexOf(char value, int startIndex);

摘要:
报告指定字符串在此实例中的最后一个匹配项的从零开始的索引位置。 在指定的字符位置开始和在向后的右边该字符串的开头处理的搜索。

参数:
value:
要搜寻的字符串。

startIndex:
搜索起始位置。 从 startIndex 此实例的开头开始搜索。

返回结果:
如果找到该字符串,则为 value 的从零开始的索引位置;如果未找到,则为 -1。或者如果当前实例等于 System.String.Empty 则也为
-1。 如果 value 为 System.String.Empty,则返回值为 startIndex 和此实例中的最后一个索引位置中的较小者。

异常:
System.ArgumentNullException:
value 为 null。

System.ArgumentOutOfRangeException:
当前实例不等于 System.String.Empty,且 startIndex 小于零,或者大于或等于当前实例的长度。 - 或 - 当前实例等于
System.String.Empty,且 startIndex 大于零。
public int LastIndexOf(string value, int startIndex);

摘要:
报告指定字符串在当前 System.String 对象中最后一个匹配项的从零开始的索引。 一个参数指定要用于指定字符串的搜索类型。

参数:
value:
要搜寻的字符串。

comparisonType:
指定搜索规则的枚举值之一。

返回结果:
如果找到该字符串,则为 value 参数的索引位置;如果未找到该字符串,则为 -1。 如果 value 为 System.String.Empty,则返回值为此实例中的最后一个索引位置。

异常:
System.ArgumentNullException:
value 为 null。

System.ArgumentException:
comparisonType 不是有效的 System.StringComparison 值。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public int LastIndexOf(string value, StringComparison comparisonType);

摘要:
报告指定的 Unicode 字符在此实例内的子字符串中的最后一个匹配项的从零开始的索引位置。 搜索在指定字符位置的数目的字符串开始时,开始指定字符和其后面的位置。

参数:
value:
要查找的 Unicode 字符。

startIndex:
搜索的起始位置。 从 startIndex 此实例的开头开始搜索。

count:
要检查的字符位置数。

返回结果:
如果找到该字符,则为 value 的从零开始的索引位置;如果未找到,则为 -1。或者如果当前实例等于 System.String.Empty 则也为
-1。

异常:
System.ArgumentOutOfRangeException:
当前实例不等于 System.String.Empty,而且 startIndex 小于零,或者大于或等于此实例的长度。 - 或 - 当前实例不等于
System.String.Empty,且 startIndex -count + 1 小于零。
[SecuritySafeCritical]
public int LastIndexOf(char value, int startIndex, int count);

摘要:
报告指定字符串在此实例中的最后一个匹配项的从零开始的索引位置。 搜索在指定字符位置的数目的字符串开始时,开始指定字符和其后面的位置。

参数:
value:
要搜寻的字符串。

startIndex:
搜索起始位置。 从 startIndex 此实例的开头开始搜索。

count:
要检查的字符位置数。

返回结果:
如果找到该字符串,则为 value 的从零开始的索引位置;如果未找到,则为 -1。或者如果当前实例等于 System.String.Empty 则也为
-1。 如果 value 为 System.String.Empty,则返回值为 startIndex 和此实例中的最后一个索引位置中的较小者。

异常:
System.ArgumentNullException:
value 为 null。

System.ArgumentOutOfRangeException:
count 为负数。 - 或 - 当前实例不等于 System.String.Empty,且 startIndex 是负数。 - 或 - 当前实例不等于
System.String.Empty,且 startIndex 大于此实例的长度。 - 或 - 当前实例不等于 System.String.Empty,且
startIndex -count + 1 指定一个不在此实例中的位置。
public int LastIndexOf(string value, int startIndex, int count);

摘要:
报告指定字符串在当前 System.String 对象中最后一个匹配项的从零开始的索引。 在指定的字符位置开始和在向后的右边该字符串的开头处理的搜索。
一个参数指定要执行搜索指定字符串的比较类型。

参数:
value:
要搜寻的字符串。

startIndex:
搜索起始位置。 从 startIndex 此实例的开头开始搜索。

comparisonType:
指定搜索规则的枚举值之一。

返回结果:
如果找到该字符串,则为 value 参数的索引位置;如果未找到,则为 -1。或者如果当前实例等于 System.String.Empty 则也为
-1。 如果 value 为 System.String.Empty,则返回值为 startIndex 和此实例中的最后一个索引位置中的较小者。

异常:
System.ArgumentNullException:
value 为 null。

System.ArgumentOutOfRangeException:
当前实例不等于 System.String.Empty,且 startIndex 小于零,或者大于或等于当前实例的长度。 - 或 - 当前实例等于
System.String.Empty,且 startIndex 大于零。

System.ArgumentException:
comparisonType 不是有效的 System.StringComparison 值。
public int LastIndexOf(string value, int startIndex, StringComparison comparisonType);

摘要:
报告指定字符串在此实例中的最后一个匹配项的从零开始的索引位置。 搜索在所指定的字符位置的数目的字符串开始时,开始指定字符和其后面的位置。 一个参数指定要执行搜索指定字符串的比较类型。

参数:
value:
要搜寻的字符串。

startIndex:
搜索起始位置。 从 startIndex 此实例的开头开始搜索。

count:
要检查的字符位置数。

comparisonType:
指定搜索规则的枚举值之一。

返回结果:
如果找到该字符串,则为 value 参数的索引位置;如果未找到,则为 -1。或者如果当前实例等于 System.String.Empty 则也为
-1。 如果 value 为 System.String.Empty,则返回值为 startIndex 和此实例中的最后一个索引位置中的较小者。

异常:
System.ArgumentNullException:
value 为 null。

System.ArgumentOutOfRangeException:
count 为负数。 - 或 - 当前实例不等于 System.String.Empty,且 startIndex 是负数。 - 或 - 当前实例不等于
System.String.Empty,且 startIndex 大于此实例的长度。 - 或 - 当前实例不等于 System.String.Empty,而且
startIndex + 1 - count 指定一个不在此实例中的位置。

System.ArgumentException:
comparisonType 不是有效的 System.StringComparison 值。
[SecuritySafeCritical]
public int LastIndexOf(string value, int startIndex, int count, StringComparison comparisonType);

摘要:
报告在 Unicode 数组中指定的一个或多个字符在此实例中的最后一个匹配项的从零开始的索引位置。

参数:
anyOf:
Unicode 字符数组,包含一个或多个要查找的字符。

返回结果:
最后一次在此实例中找到 anyOf 中的任意字符的索引位置;如果未找到 anyOf 中的字符,则为 -1。

异常:
System.ArgumentNullException:
anyOf 为 null。
public int LastIndexOfAny(char[] anyOf);

摘要:
报告在 Unicode 数组中指定的一个或多个字符在此实例中的最后一个匹配项的从零开始的索引位置。 在指定的字符位置开始和在向后的右边该字符串的开头处理的搜索。

参数:
anyOf:
Unicode 字符数组,包含一个或多个要查找的字符。

startIndex:
搜索起始位置。 从 startIndex 此实例的开头开始搜索。

返回结果:
最后一次在此实例中找到 anyOf 中的任意字符的索引位置;如果未找到 anyOf 中的字符或者当前实例等于System.String.Empty,则为
-1。

异常:
System.ArgumentNullException:
anyOf 为 null。

System.ArgumentOutOfRangeException:
当前实例不等于 System.String.Empty,而且 startIndex 指定一个不在此实例中的位置。
public int LastIndexOfAny(char[] anyOf, int startIndex);

摘要:
报告在 Unicode 数组中指定的一个或多个字符在此实例中的最后一个匹配项的从零开始的索引位置。 搜索在指定字符位置的数目的字符串开始时,开始指定字符和其后面的位置。

参数:
anyOf:
Unicode 字符数组,包含一个或多个要查找的字符。

startIndex:
搜索起始位置。 从 startIndex 此实例的开头开始搜索。

count:
要检查的字符位置数。

返回结果:
最后一次在此实例中找到 anyOf 中的任意字符的索引位置;如果未找到 anyOf 中的字符或者当前实例等于System.String.Empty,则为
-1。

异常:
System.ArgumentNullException:
anyOf 为 null。

System.ArgumentOutOfRangeException:
当前实例不等于 System.String.Empty,且 count 或 startIndex 是负数。 - 或 - 当前实例不等于 System.String.Empty,而且
startIndex 减去 count 指定一个不在此实例中的位置。
[SecuritySafeCritical]
public int LastIndexOfAny(char[] anyOf, int startIndex, int count);

摘要:
返回一个新字符串,其文本值与此字符串相同,但其二进制表示形式符合 Unicode 范式 C。

返回结果:
一个新的规范化字符串,其文本值与此字符串相同,但其二进制表示形式符合范式 C。

异常:
System.ArgumentException:
当前实例包含无效的 Unicode 字符。
public string Normalize();

摘要:
返回一个新字符串,其文本值与此字符串相同,但其二进制表示形式符合指定的 Unicode 范式。

参数:
normalizationForm:
一个 Unicode 范式。

返回结果:
一个新字符串,其文本值与此字符串相同,但其二进制表示形式符合由 normalizationForm 参数指定的范式。

异常:
System.ArgumentException:
当前实例包含无效的 Unicode 字符。
[SecuritySafeCritical]
public string Normalize(NormalizationForm normalizationForm);

摘要:
返回一个新字符串,该字符串通过在此实例中的字符左侧填充空格来达到指定的总长度,从而实现右对齐。

参数:
totalWidth:
结果字符串中的字符数,等于原始字符数加上任何其他填充字符。

返回结果:
与此实例等效的一个新字符串,但该字符串为右对齐,因此,在左侧填充所需数量的空格,使长度达到 totalWidth。 但是,如果 totalWidth
小于此事例的长度,则方法将返回对现有实例的引用。 如果 totalWidth 等于此实例的长度,则返回为与此实例相同的新字符串。

异常:
System.ArgumentOutOfRangeException:
totalWidth 小于零。
public string PadLeft(int totalWidth);

摘要:
返回一个新字符串,该字符串通过在此实例中的字符左侧填充指定的 Unicode 字符来达到指定的总长度,从而使这些字符右对齐。

参数:
totalWidth:
结果字符串中的字符数,等于原始字符数加上任何其他填充字符。

paddingChar:
Unicode 填充字符。

返回结果:
与此实例等效的一个新字符串,但该字符串为右对齐,因此,在左侧填充所需任意数量的 paddingChar 字符,使长度达到 totalWidth。
但是,如果 totalWidth 小于此事例的长度,则方法将返回对现有实例的引用。 如果 totalWidth 等于此实例的长度,则返回为与此实例相同的新字符串。

异常:
System.ArgumentOutOfRangeException:
totalWidth 小于零。
public string PadLeft(int totalWidth, char paddingChar);

摘要:
返回一个新字符串,该字符串通过在此字符串中的字符右侧填充空格来达到指定的总长度,从而使这些字符左对齐。

参数:
totalWidth:
结果字符串中的字符数,等于原始字符数加上任何其他填充字符。

返回结果:
与此实例等效的一个新字符串,但该字符串为左对齐,因此,在右侧填充所需任意数量的空格,使长度达到 totalWidth。 但是,如果 totalWidth
小于此事例的长度,则方法将返回对现有实例的引用。 如果 totalWidth 等于此实例的长度,则返回为与此实例相同的新字符串。

异常:
System.ArgumentOutOfRangeException:
totalWidth 小于零。
public string PadRight(int totalWidth);

摘要:
返回一个新字符串,该字符串通过在此字符串中的字符右侧填充指定的 Unicode 字符来达到指定的总长度,从而使这些字符左对齐。

参数:
totalWidth:
结果字符串中的字符数,等于原始字符数加上任何其他填充字符。

paddingChar:
Unicode 填充字符。

返回结果:
与此实例等效的一个新字符串,但该字符串为左对齐,因此,在右侧填充所需任意数量的 paddingChar 字符,使长度达到 totalWidth。
但是,如果 totalWidth 小于此事例的长度,则方法将返回对现有实例的引用。 如果 totalWidth 等于此实例的长度,则返回为与此实例相同的新字符串。

异常:
System.ArgumentOutOfRangeException:
totalWidth 小于零。
public string PadRight(int totalWidth, char paddingChar);

摘要:
返回当前实例中从指定位置到最后位置的所有以删除的字符的新字符串。

参数:
startIndex:
开始删除字符的从零开始的位置。

返回结果:
一个新字符串,除所删除的字符之外,该字符串与此字符串等效。

异常:
System.ArgumentOutOfRangeException:
startIndex 小于零。 - 或 - startIndex 指定的位置不在此字符串内。
public string Remove(int startIndex);

摘要:
返回指定数量字符在当前这个实例起始点在已删除的指定的位置的新字符串。

参数:
startIndex:
开始删除字符的从零开始的位置。

count:
要删除的字符数。

返回结果:
一个新字符串,除所删除的字符之外,该字符串与此实例等效。

异常:
System.ArgumentOutOfRangeException:
startIndex 或 count 小于零。 - 或 - startIndex 加 count 之和指定一个此实例外的位置。
[SecuritySafeCritical]
public string Remove(int startIndex, int count);

摘要:
返回一个新字符串,其中此实例中出现的所有指定 Unicode 字符都替换为另一个指定的 Unicode 字符。

参数:
oldChar:
要被替换的 Unicode 字符。

newChar:
要替换出现的所有 oldChar 的 Unicode 字符。

返回结果:
等效于此实例(除了 oldChar 的所有实例都已替换为 newChar 外)的字符串。
public string Replace(char oldChar, char newChar);

摘要:
返回一个新字符串,其中当前实例中出现的所有指定字符串都替换为另一个指定的字符串。

参数:
oldValue:
要被替换的字符串。

newValue:
要替换出现的所有 oldValue 的字符串。

返回结果:
等效于当前字符串(除了 oldValue 的所有实例都已替换为 newValue 外)的字符串。

异常:
System.ArgumentNullException:
oldValue 为 null。

System.ArgumentException:
oldValue 是空字符串 ("")。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public string Replace(string oldValue, string newValue);

摘要:
返回的字符串数组包含此实例中的子字符串(由指定 Unicode 字符数组的元素分隔)。

参数:
separator:
分隔此实例中子字符串的 Unicode 字符数组、不包含分隔符的空数组或 null。

返回结果:
一个数组,其元素包含此实例中的子字符串,这些子字符串由 separator 中的一个或多个字符分隔。 有关更多信息,请参见“备注”一节。
public string[] Split(params char[] separator);

摘要:
返回的字符串数组包含此实例中的子字符串(由指定 Unicode 字符数组的元素分隔)。 参数指定返回的子字符串的最大数量。

参数:
separator:
分隔此实例中子字符串的 Unicode 字符数组、不包含分隔符的空数组或 null。

count:
要返回的子字符串的最大数量。

返回结果:
一个数组,其元素包含此实例中的子字符串,这些子字符串由 separator 中的一个或多个字符分隔。 有关更多信息,请参见“备注”一节。

异常:
System.ArgumentOutOfRangeException:
count 为负数。
public string[] Split(char[] separator, int count);

摘要:
返回的字符串数组包含此字符串中的子字符串(由指定 Unicode 字符数组的元素分隔)。 参数指定是否返回空数组元素。

参数:
separator:
分隔此字符串中子字符串的 Unicode 字符数组、不包含分隔符的空数组或 null。

options:
要省略返回的数组中的空数组元素,则为 System.StringSplitOptions.RemoveEmptyEntries;要包含返回的数组中的空数组元素,则为
System.StringSplitOptions.None。

返回结果:
一个数组,其元素包含此字符串中的子字符串,这些子字符串由 separator 中的一个或多个字符分隔。 有关更多信息,请参见“备注”一节。

异常:
System.ArgumentException:
options 不是 System.StringSplitOptions 值之一。
[ComVisible(false)]
public string[] Split(char[] separator, StringSplitOptions options);

摘要:
返回的字符串数组包含此字符串中的子字符串(由指定字符串数组的元素分隔)。 参数指定是否返回空数组元素。

参数:
separator:
分隔此字符串中子字符串的字符串数组、不包含分隔符的空数组或 null。

options:
要省略返回的数组中的空数组元素,则为 System.StringSplitOptions.RemoveEmptyEntries;要包含返回的数组中的空数组元素,则为
System.StringSplitOptions.None。

返回结果:
一个数组,其元素包含此字符串中的子字符串,这些子字符串由 separator 中的一个或多个字符串分隔。 有关更多信息,请参见“备注”一节。

异常:
System.ArgumentException:
options 不是 System.StringSplitOptions 值之一。
[ComVisible(false)]
public string[] Split(string[] separator, StringSplitOptions options);

摘要:
返回的字符串数组包含此字符串中的子字符串(由指定 Unicode 字符数组的元素分隔)。 参数指定要返回子字符串的最大数量,以及是否返回空数组元素。

参数:
separator:
分隔此字符串中子字符串的 Unicode 字符数组、不包含分隔符的空数组或 null。

count:
要返回的子字符串的最大数量。

options:
要省略返回的数组中的空数组元素,则为 System.StringSplitOptions.RemoveEmptyEntries;要包含返回的数组中的空数组元素,则为
System.StringSplitOptions.None。

返回结果:
一个数组,其元素包含此字符串中的子字符串,这些子字符串由 separator 中的一个或多个字符分隔。 有关更多信息,请参见“备注”一节。

异常:
System.ArgumentOutOfRangeException:
count 为负数。

System.ArgumentException:
options 不是 System.StringSplitOptions 值之一。
[ComVisible(false)]
public string[] Split(char[] separator, int count, StringSplitOptions options);

摘要:
返回的字符串数组包含此字符串中的子字符串(由指定字符串数组的元素分隔)。 参数指定要返回子字符串的最大数量,以及是否返回空数组元素。

参数:
separator:
分隔此字符串中子字符串的字符串数组、不包含分隔符的空数组或 null。

count:
要返回的子字符串的最大数量。

options:
要省略返回的数组中的空数组元素,则为 System.StringSplitOptions.RemoveEmptyEntries;要包含返回的数组中的空数组元素,则为
System.StringSplitOptions.None。

返回结果:
一个数组,其元素包含此字符串中的子字符串,这些子字符串由 separator 中的一个或多个字符串分隔。 有关更多信息,请参见“备注”一节。

异常:
System.ArgumentOutOfRangeException:
count 为负数。

System.ArgumentException:
options 不是 System.StringSplitOptions 值之一。
[ComVisible(false)]
public string[] Split(string[] separator, int count, StringSplitOptions options);

摘要:
确定此字符串实例的开头是否与指定的字符串匹配。

参数:
value:
要比较的字符串。

返回结果:
如果 value 与此字符串的开头匹配,则为 true;否则为 false。

异常:
System.ArgumentNullException:
value 为 null。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public bool StartsWith(string value);

摘要:
确定在使用指定的比较选项进行比较时此字符串实例的开头是否与指定的字符串匹配。

参数:
value:
要比较的字符串。

comparisonType:
枚举值之一,用于确定如何比较此字符串与 value。

返回结果:
true(如果该实例以 value 开头;否则为 false)。

异常:
System.ArgumentNullException:
value 为 null。

System.ArgumentException:
comparisonType 不是一个 System.StringComparison 值。
[ComVisible(false)]
[SecuritySafeCritical]
public bool StartsWith(string value, StringComparison comparisonType);

摘要:
确定在使用指定的区域性进行比较时此字符串实例的开头是否与指定的字符串匹配。

参数:
value:
要比较的字符串。

ignoreCase:
要在比较过程中忽略大小写,则为 true;否则为 false。

culture:
确定如何对此字符串与 value 进行比较的区域性信息。 如果 culture 为 null,则使用当前区域性。

返回结果:
如果 value 参数与此字符串的开头匹配,则为 true;否则为 false。

异常:
System.ArgumentNullException:
value 为 null。
public bool StartsWith(string value, bool ignoreCase, CultureInfo culture);

摘要:
从此实例检索子字符串。 子字符串从指定的字符位置开始。

参数:
startIndex:
此实例中子字符串的起始字符位置(从零开始)。

返回结果:
与此实例中在 startIndex 处开头的子字符串等效的一个字符串;如果 startIndex 等于此实例的长度,则为 System.String.Empty。

异常:
System.ArgumentOutOfRangeException:
startIndex 小于零或大于此实例的长度。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public string Substring(int startIndex);

摘要:
从此实例检索子字符串。 子字符串从指定的字符位置开始且具有指定的长度。

参数:
startIndex:
此实例中子字符串的起始字符位置(从零开始)。

length:
子字符串中的字符数。

返回结果:
与此实例中在 startIndex 处开头、长度为 length 的子字符串等效的一个字符串,如果 startIndex 等于此实例的长度且 length
为零,则为 System.String.Empty。

异常:
System.ArgumentOutOfRangeException:
startIndex 加 length 之和指示的位置不在此实例中。 - 或 - startIndex 或 length 小于零。
[SecuritySafeCritical]
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public string Substring(int startIndex, int length);

摘要:
将此实例中的字符复制到 Unicode 字符数组。

返回结果:
元素为此实例的各字符的 Unicode 字符数组。 如果此实例是空字符串,则返回的数组为空且长度为零。
[SecuritySafeCritical]
public char[] ToCharArray();

摘要:
将此实例中的指定子字符串内的字符复制到 Unicode 字符数组。

参数:
startIndex:
此实例内子字符串的起始位置。

length:
此实例内子字符串的长度。

返回结果:
元素为此实例中从字符位置 startIndex 开始的 length 字符数的 Unicode 字符数组。

异常:
System.ArgumentOutOfRangeException:
startIndex 或 length 小于零。 - 或 - startIndex 加上 length 大于此实例的长度。
[SecuritySafeCritical]
public char[] ToCharArray(int startIndex, int length);

摘要:
返回此字符串转换为小写形式的副本。

返回结果:
一个小写字符串。
public string ToLower();

摘要:
根据指定区域性的大小写规则返回此字符串转换为小写形式的副本。

参数:
culture:
一个对象,用于提供区域性特定的大小写规则。

返回结果:
当前字符串的等效小写形式。

异常:
System.ArgumentNullException:
culture 为 null。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public string ToLower(CultureInfo culture);

摘要:
返回此 System.String 对象的转换为小写形式的副本,返回时使用固定区域性的大小写规则。

返回结果:
当前字符串的等效小写形式。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public string ToLowerInvariant();

摘要:
返回 System.String 的此实例;不执行实际转换。

返回结果:
当前的字符串。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public override string ToString();

摘要:
返回 System.String 的此实例;不执行实际转换。

参数:
provider:
(保留)一个对象,用于提供区域性特定的格式设置信息。

返回结果:
当前的字符串。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public string ToString(IFormatProvider provider);

摘要:
返回此字符串转换为大写形式的副本。

返回结果:
当前字符串的大写形式。
public string ToUpper();

摘要:
根据指定区域性的大小写规则返回此字符串转换为大写形式的副本。

参数:
culture:
一个对象,用于提供区域性特定的大小写规则。

返回结果:
当前字符串的大写形式。

异常:
System.ArgumentNullException:
culture 为 null。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public string ToUpper(CultureInfo culture);

摘要:
返回此 System.String 对象的转换为大写形式的副本,返回时使用固定区域性的大小写规则。

返回结果:
当前字符串的大写形式。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public string ToUpperInvariant();

摘要:
从当前 System.String 对象移除所有前导空白字符和尾部空白字符。

返回结果:
从当前字符串的开头和结尾删除所有空白字符后剩余的字符串。
public string Trim();

摘要:
从当前 System.String 对象移除数组中指定的一组字符的所有前导匹配项和尾部匹配项。

参数:
trimChars:
要删除的 Unicode 字符的数组,或 null。

返回结果:
从当前字符串的开头和结尾删除所出现的所有 trimChars 参数中的字符后剩余的字符串。 如果 trimChars 为 null 或空数组,则改为移除空白字符。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public string Trim(params char[] trimChars);

摘要:
从当前 System.String 对象移除数组中指定的一组字符的所有尾部匹配项。

参数:
trimChars:
要删除的 Unicode 字符的数组,或 null。

返回结果:
从当前字符串的结尾移除所出现的所有 trimChars 参数中的字符后剩余的字符串。 如果 trimChars 为 null 或空数组,则改为删除
Unicode 空白字符。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public string TrimEnd(params char[] trimChars);

摘要:
从当前 System.String 对象移除数组中指定的一组字符的所有前导匹配项。

参数:
trimChars:
要删除的 Unicode 字符的数组,或 null。

返回结果:
从当前字符串的开头移除所出现的所有 trimChars 参数中的字符后剩余的字符串。 如果 trimChars 为 null 或空数组,则改为移除空白字符。
[TargetedPatchingOptOut("Performance critical to inline across NGen image boundaries")]
public string TrimStart(params char[] trimChars);

posted @ 2021-01-22 13:54  飞渝  阅读(143)  评论(0)    收藏  举报