执行不区分区域性的字符串操作Performing culture-insensitive string operations

默认情况下,大多数执行区域性敏感型字符串操作的 .NET Framework 方法提供方法重载,以便于通过传递 CultureInfo 参数来显式指定要使用的区域性。Most .NET Framework methods that perform culture-sensitive string operations by default provide method overloads that allow you to explicitly specify the culture to use by passing a CultureInfo parameter. 这些重载允许消除大小写映射和排序规则中的区域性差异,保证获得不区分区域性的结果。These overloads allow you to eliminate cultural variations in case mappings and sorting rules and guarantee culture-insensitive results.

本节提供以下主题,用以说明如何使用默认区分区域性的 .NET Framework 方法执行不区分区域性的字符串操作。This section provides the following topics to demonstrate how to perform culture-insensitive string operations using .NET Framework methods that are culture-sensitive by default.

本节内容In this section

执行不区分区域性的字符串比较Performing Culture-Insensitive String Comparisons
介绍了如何使用 String.CompareString.CompareTo 方法执行非区域性敏感型字符串比较。Describes how to use the String.Compare and String.CompareTo methods to perform culture-insensitive string comparisons.

执行不区分区域性的大小写更改Performing Culture-Insensitive Case Changes
介绍了如何使用 String.ToUpperString.ToLowerChar.ToUpperChar.ToLower 方法执行非区域性敏感型大小写更改。Describes how to use the String.ToUpper, String.ToLower, Char.ToUpper, and Char.ToLower methods to perform culture-insensitive case changes.

在集合中执行不区分区域性的字符串操作Performing Culture-Insensitive String Operations in Collections
介绍了如何使用 CaseInsensitiveComparerCaseInsensitiveHashCodeProvider 类、SortedListArrayList.SortCollectionsUtil.CreateCaseInsensitiveHashtable 在集合中执行非区域性敏感型操作。Describes how to use the CaseInsensitiveComparer, CaseInsensitiveHashCodeProvider class, SortedList, ArrayList.Sort and CollectionsUtil.CreateCaseInsensitiveHashtable to perform culture-insensitive operations in collections.

在数组中执行不区分区域性的字符串操作Performing Culture-Insensitive String Operations in Arrays
介绍了如何使用 Array.SortArray.BinarySearch 方法在数组中执行非区域性敏感型操作。Describes how to use the Array.Sort and Array.BinarySearch methods to perform culture-insensitive operations in arrays.

不区分区域性的字符串操作Culture-Insensitive String Operations
介绍对字符串执行操作时应了解区域性的原因,并为何时执行区分区域性的操作、何时执行不区分区域性的操作提供了指南。Describes why you should be aware of culture when performing operations on strings and provides guidelines for when to perform culture-sensitive operations and when to perform culture-insensitive operations.

另请参阅See also