CompareOptions Výčet
Definice
Důležité
Některé informace platí pro předběžně vydaný produkt, který se může zásadně změnit, než ho výrobce nebo autor vydá. Microsoft neposkytuje žádné záruky, výslovné ani předpokládané, týkající se zde uváděných informací.
Definuje možnosti porovnání řetězců, které se mají použít s CompareInfo.
Tento výčet podporuje bitové kombinace hodnot jeho členů.
public enum class CompareOptions
[System.Flags]
public enum CompareOptions
[System.Flags]
[System.Serializable]
public enum CompareOptions
[System.Flags]
[System.Serializable]
[System.Runtime.InteropServices.ComVisible(true)]
public enum CompareOptions
[<System.Flags>]
type CompareOptions =
[<System.Flags>]
[<System.Serializable>]
type CompareOptions =
[<System.Flags>]
[<System.Serializable>]
[<System.Runtime.InteropServices.ComVisible(true)>]
type CompareOptions =
Public Enum CompareOptions
- Dědičnost
- Atributy
Pole
| Name | Hodnota | Description |
|---|---|---|
| None | 0 | Porovnání řetězců s výchozím nastavením možností |
| IgnoreCase | 1 | Porovnání řetězců, které ignoruje rozdíly mezi písmeny. |
| IgnoreNonSpace | 2 | Porovnání řetězců, které ignoruje nekombinující znaky, jako jsou diakritická znaménka. Neuložení znaků mění základní znaky, aniž by zabíraly vlastní mezery. Standard Unicode definuje kombinování znaků jako znaků, které jsou kombinovány se základními znaky pro vytvoření nového znaku. |
| IgnoreSymbols | 4 | Porovnání řetězců, které ignoruje symboly, včetně prázdných znaků, interpunkce, symbolů měny, znaku procenta, matematických symbolů, ampersandu a podobných znaků. |
| IgnoreKanaType | 8 | Porovnání řetězců, které ignoruje typ kana. Typ Kana odkazuje na japonské znaky hiragana a katakana, které představují fonetické zvuky. Hiragana se používá pro nativní japonská slova, zatímco katakana se používá pro slova půjčovaná z jiných jazyků. S touto možností jsou znaky hiragana a katakana, které představují stejný zvuk, považovány za stejné. |
| IgnoreWidth | 16 | Porovnání řetězců, které ignoruje šířku znaků. Například znaky katakana s plnou šířkou a poloviční šířkou jsou považovány za stejné jako u této možnosti. |
| NumericOrdering | 32 | Porovnání řetězců, které seřadí posloupnosti číslic (obecná kategorie Unicode "Nd") na základě jejich číselné hodnoty. Například "2" přichází před "10". Neciferné znaky, jako jsou desetinné čárky, mínus a znaménka plus, se nepovažují za součást sekvence a ukončí je. Tento příznak není platný pro metody indexování (například IndexOf(String, String, CompareOptions) a IsPrefix(String, String, CompareOptions)). |
| OrdinalIgnoreCase | 268435456 | Porovnání řetězců, které ignoruje malá a velká písmena, pak provede řadové porovnání. Tato technika je ekvivalentní převodu řetězce na velká písmena pomocí invariantní jazykové verze a následné provedení řadového porovnání výsledku.
|
| StringSort | 536870912 | Porovnání řetězců, které používá algoritmus řazení řetězců, kde se před alfanumerickými znaky seřadí jiné než osamocené symboly (například spojovníky a apostrofy). |
| Ordinal | 1073741824 | Porovnání řetězců, které používá kódované hodnoty unicode UTF-16 řetězců a porovnává je jednotku kódu podle jednotky kódu. Výsledkem je rychlé porovnání nerozlišující jazykovou verzi, kdy jsou řetězce seřazené pouze na základě jejich binárních hodnot. Tuto možnost nelze kombinovat s jinými CompareOptions hodnotami a je nutné ji použít samostatně. |
Příklady
Následující příklad kódu ukazuje, jak každá z CompareOptions hodnot ovlivňuje porovnání řetězců.
using System;
using System.Globalization;
public class CompareOptionsExample
{
public static void Run()
{
// Uppercase and lowercase characters are equivalent (according to the culture rules)
// when IgnoreCase is used.
TestStringEquality("ONE two", "one TWO", "Case sensitivity", CompareOptions.IgnoreCase);
// Punctuation is ignored with the IgnoreSymbols option.
TestStringEquality("hello world", "hello, world!", "Punctuation", CompareOptions.IgnoreSymbols);
// Whitespace and mathematical symbols are also ignored with IgnoreSymbols.
TestStringEquality("3 + 5 = 8", "358", "Whitespace and mathematical symbols", CompareOptions.IgnoreSymbols);
// Caution: currency symbols and thousands separators are ignored with IgnoreSymbols.
// Parse strings containing numbers/currency and compare them numerically instead.
TestStringEquality("Total $15,000", "Total: £150.00", "Currency symbols, decimals and thousands separators", CompareOptions.IgnoreSymbols);
// Full width characters are common in East Asian languages. Use the IgnoreWidth
// option to treat full- and half-width characters as equal.
TestStringEquality("abc,-", "abc,-", "Half width and full width characters", CompareOptions.IgnoreWidth);
// The same string in Hiragana and Katakana is equal when IgnoreKanaType is used.
TestStringEquality("ありがとう", "アリガトウ", "Hiragana and Katakana strings", CompareOptions.IgnoreKanaType);
// When comparing with the IgnoreNonSpace option, characters like diacritical marks are ignored.
TestStringEquality("café", "cafe", "Diacritical marks", CompareOptions.IgnoreNonSpace);
// Ligature characters and their non-ligature forms compare equal with the IgnoreNonSpace option.
// Note: prior to .NET 5, ligature characters were equal to their expanded forms by default.
TestStringEquality("straße œuvre cæsar", "strasse oeuvre caesar", "Ligature characters", CompareOptions.IgnoreNonSpace);
}
private static void TestStringEquality(string str1, string str2, string description, CompareOptions options)
{
Console.WriteLine(Environment.NewLine + description + ":");
// First test with the default CompareOptions then with the provided options
TestStringEquality(str1, str2, CompareOptions.None);
TestStringEquality(str1, str2, options);
}
private static void TestStringEquality(string str1, string str2, CompareOptions options)
{
Console.Write($" When using CompareOptions.{options}, \"{str1}\" and \"{str2}\" are ");
if (string.Compare(str1, str2, CultureInfo.InvariantCulture, options) != 0)
{
Console.Write("not ");
}
Console.WriteLine("equal.");
}
}
/*
In .NET 5 and later, the output is the following:
Case sensitivity:
When using CompareOptions.None, "ONE two" and "one TWO" are not equal.
When using CompareOptions.IgnoreCase, "ONE two" and "one TWO" are equal.
Punctuation:
When using CompareOptions.None, "hello world" and "hello, world!" are not equal.
When using CompareOptions.IgnoreSymbols, "hello world" and "hello, world!" are equal.
Whitespace and mathematical symbols:
When using CompareOptions.None, "3 + 5 = 8" and "358" are not equal.
When using CompareOptions.IgnoreSymbols, "3 + 5 = 8" and "358" are equal.
Currency symbols, decimals and thousands separators:
When using CompareOptions.None, "Total $15,000" and "Total: £150.00" are not equal.
When using CompareOptions.IgnoreSymbols, "Total $15,000" and "Total: £150.00" are equal.
Half width and full width characters:
When using CompareOptions.None, "abc,-" and "abc,-" are not equal.
When using CompareOptions.IgnoreWidth, "abc,-" and "abc,-" are equal.
Hiragana and Katakana strings:
When using CompareOptions.None, "ありがとう" and "アリガトウ" are not equal.
When using CompareOptions.IgnoreKanaType, "ありがとう" and "アリガトウ" are equal.
Diacritical marks:
When using CompareOptions.None, "café" and "cafe" are not equal.
When using CompareOptions.IgnoreNonSpace, "café" and "cafe" are equal.
Ligature characters:
When using CompareOptions.None, "straße œuvre cæsar" and "strasse oeuvre caesar" are not equal.
When using CompareOptions.IgnoreNonSpace, "straße œuvre cæsar" and "strasse oeuvre caesar" are equal.
Note: When using .NET versions prior to .NET 5, ligature characters compare as equal to their
non-ligature counterparts by default, so the last test will output as follows:
Ligature characters:
When using CompareOptions.None, "straße œuvre cæsar" and "strasse oeuvre caesar" are equal.
When using CompareOptions.IgnoreNonSpace, "straße œuvre cæsar" and "strasse oeuvre caesar" are equal.
*/
module compareoptions_values
open System
open System.Globalization
let testStringEquality (str1: string) (str2: string) (description: string) (options: CompareOptions) =
printfn "\n%s:" description
let compareAndPrint opts =
let result = String.Compare(str1, str2, CultureInfo.InvariantCulture, opts)
let equalityStatus = if result = 0 then "equal" else "not equal"
printfn " When using CompareOptions.%A, \"%s\" and \"%s\" are %s." opts str1 str2 equalityStatus
compareAndPrint CompareOptions.None
compareAndPrint options
[<EntryPoint>]
let main argv =
// Uppercase and lowercase characters are equivalent (according to the culture rules) when IgnoreCase is used.
testStringEquality "ONE two" "one TWO" "Case sensitivity" CompareOptions.IgnoreCase
// Punctuation is ignored with the IgnoreSymbols option.
testStringEquality "hello world" "hello, world!" "Punctuation" CompareOptions.IgnoreSymbols
// Whitespace and mathematical symbols are also ignored with IgnoreSymbols.
testStringEquality "3 + 5 = 8" "358" "Whitespace and mathematical symbols" CompareOptions.IgnoreSymbols
// Caution: currency symbols and thousands separators are ignored with IgnoreSymbols.
// Parse strings containing numbers/currency and compare them numerically instead.
testStringEquality "Total $15,000" "Total: £150.00" "Currency symbols, decimals and thousands separators" CompareOptions.IgnoreSymbols
// Full width characters are common in East Asian languages. Use the IgnoreWidth
// option to treat full- and half-width characters as equal.
testStringEquality "abc,-" "abc,-" "Half width and full width characters" CompareOptions.IgnoreWidth
// The same string in Hiragana and Katakana is equal when IgnoreKanaType is used.
testStringEquality "ありがとう" "アリガトウ" "Hiragana and Katakana strings" CompareOptions.IgnoreKanaType
// When comparing with the IgnoreNonSpace option, characters like diacritical marks are ignored.
testStringEquality "café" "cafe" "Diacritical marks" CompareOptions.IgnoreNonSpace
// Ligature characters and their non-ligature forms compare equal with the IgnoreNonSpace option.
// Note: prior to .NET 5, ligature characters were equal to their expanded forms by default.
testStringEquality "straße œuvre cæsar" "strasse oeuvre caesar" "Ligature characters" CompareOptions.IgnoreNonSpace
0 // return an integer exit code
(*
In .NET 5 and later, the output will be the following:
Case sensitivity:
When using CompareOptions.None, "ONE two" and "one TWO" are not equal.
When using CompareOptions.IgnoreCase, "ONE two" and "one TWO" are equal.
Punctuation:
When using CompareOptions.None, "hello world" and "hello, world!" are not equal.
When using CompareOptions.IgnoreSymbols, "hello world" and "hello, world!" are equal.
Whitespace and mathematical symbols:
When using CompareOptions.None, "3 + 5 = 8" and "358" are not equal.
When using CompareOptions.IgnoreSymbols, "3 + 5 = 8" and "358" are equal.
Currency symbols, decimals and thousands separators:
When using CompareOptions.None, "Total $15,000" and "Total: £150.00" are not equal.
When using CompareOptions.IgnoreSymbols, "Total $15,000" and "Total: £150.00" are equal.
Half width and full width characters:
When using CompareOptions.None, "abc,-" and "abc,-" are not equal.
When using CompareOptions.IgnoreWidth, "abc,-" and "abc,-" are equal.
Hiragana and Katakana strings:
When using CompareOptions.None, "ありがとう" and "アリガトウ" are not equal.
When using CompareOptions.IgnoreKanaType, "ありがとう" and "アリガトウ" are equal.
Diacritical marks:
When using CompareOptions.None, "café" and "cafe" are not equal.
When using CompareOptions.IgnoreNonSpace, "café" and "cafe" are equal.
Ligature characters:
When using CompareOptions.None, "straße œuvre cæsar" and "strasse oeuvre caesar" are not equal.
When using CompareOptions.IgnoreNonSpace, "straße œuvre cæsar" and "strasse oeuvre caesar" are equal.
Note: when using .NET versions prior to .NET 5, ligature characters compare as equal to their
non-ligature counterparts by default, so the last test will output as follows:
Ligature characters:
When using CompareOptions.None, "straße œuvre cæsar" and "strasse oeuvre caesar" are equal.
When using CompareOptions.IgnoreNonSpace, "straße œuvre cæsar" and "strasse oeuvre caesar" are equal.
*)
Imports System
Imports System.Globalization
Module CompareOptionsExample
Sub Main()
' Uppercase and lowercase characters are equivalent (according to the culture rules)
' when IgnoreCase is used.
TestStringEquality("ONE two", "one TWO", "Case sensitivity", CompareOptions.IgnoreCase)
' Punctuation is ignored with the IgnoreSymbols option.
TestStringEquality("hello world", "hello, world!", "Punctuation", CompareOptions.IgnoreSymbols)
' Whitespace and mathematical symbols are also ignored with IgnoreSymbols.
TestStringEquality("3 + 5 = 8", "358", "Whitespace and mathematical symbols", CompareOptions.IgnoreSymbols)
' Caution: currency symbols and thousands separators are ignored with IgnoreSymbols.
' Parse strings containing numbers/currency and compare them numerically instead.
TestStringEquality("Total $15,000", "Total: £150.00", "Currency symbols, decimals and thousands separators", CompareOptions.IgnoreSymbols)
' Full width characters are common in East Asian languages. Use the IgnoreWidth
' option to treat full- and half-width characters as equal.
TestStringEquality("abc,-", "abc,-", "Half width and full width characters", CompareOptions.IgnoreWidth)
' The same string in Hiragana and Katakana is equal when IgnoreKanaType is used.
TestStringEquality("ありがとう", "アリガトウ", "Hiragana and Katakana strings", CompareOptions.IgnoreKanaType)
' When comparing with the IgnoreNonSpace option, characters like diacritical marks are ignored.
TestStringEquality("café", "cafe", "Diacritical marks", CompareOptions.IgnoreNonSpace)
' Ligature characters and their non-ligature forms compare equal with the IgnoreNonSpace option.
' Note: prior to .NET 5, ligature characters were equal to their expanded forms by default.
TestStringEquality("straße œuvre cæsar", "strasse oeuvre caesar", "Ligature characters", CompareOptions.IgnoreNonSpace)
End Sub
Private Sub TestStringEquality(str1 As String, str2 As String, description As String, options As CompareOptions)
Console.WriteLine(Environment.NewLine & description & ":")
' First test with the default CompareOptions then with the provided options
TestStringEqualityWithOptions(str1, str2, CompareOptions.None)
TestStringEqualityWithOptions(str1, str2, options)
End Sub
Private Sub TestStringEqualityWithOptions(str1 As String, str2 As String, options As CompareOptions)
Console.Write($" When using CompareOptions.{options}, ""{str1}"" and ""{str2}"" are ")
If String.Compare(str1, str2, CultureInfo.InvariantCulture, options) <> 0 Then
Console.Write("not ")
End If
Console.WriteLine("equal.")
End Sub
End Module
' In .NET 5 and later, the output is the following:
'
'Case sensitivity :
' When using CompareOptions.None, "ONE two" and "one TWO" are not equal.
' When using CompareOptions.IgnoreCase, "ONE two" and "one TWO" are equal.
'
'Punctuation:
' When using CompareOptions.None, "hello world" and "hello, world!" are not equal.
' When using CompareOptions.IgnoreSymbols, "hello world" and "hello, world!" are equal.
'
'Whitespace And mathematical symbols:
' When using CompareOptions.None, "3 + 5 = 8" and "358" are not equal.
' When using CompareOptions.IgnoreSymbols, "3 + 5 = 8" and "358" are equal.
'
'Currency symbols, decimals And thousands separators:
' When using CompareOptions.None, "Total $15,000" and "Total: £150.00" are not equal.
' When using CompareOptions.IgnoreSymbols, "Total $15,000" and "Total: £150.00" are equal.
'
'Half width And full width characters:
' When using CompareOptions.None, "abc,-" and "abc,-" are not equal.
' When using CompareOptions.IgnoreWidth, "abc,-" and "abc,-" are equal.
'
'Hiragana And Katakana strings:
' When using CompareOptions.None, "ありがとう" and "アリガトウ" are not equal.
' When using CompareOptions.IgnoreKanaType, "ありがとう" and "アリガトウ" are equal.
'
'Diacritical marks :
' When using CompareOptions.None, "café" and "cafe" are not equal.
' When using CompareOptions.IgnoreNonSpace, "café" and "cafe" are equal.
'
'Ligature characters :
' When using CompareOptions.None, "straße œuvre cæsar" and "strasse oeuvre caesar" are not equal.
' When using CompareOptions.IgnoreNonSpace, "straße œuvre cæsar" and "strasse oeuvre caesar" are equal.
'
' Note: when using .NET versions prior to .NET 5, ligature characters compare as equal to their
' non-ligature counterparts by default, so the last test will output as follows:
'
'Ligature characters :
' When using CompareOptions.None, "straße œuvre cæsar" and "strasse oeuvre caesar" are equal.
' When using CompareOptions.IgnoreNonSpace, "straße œuvre cæsar" and "strasse oeuvre caesar" are equal.
Následující příklad kódu ukazuje, jak se řazení liší StringSort od řazení bez StringSort.
using System;
using System.Collections.Generic;
using System.Globalization;
public class StringSort
{
public static void Run()
{
var wordList = new List<string>
{
"cant", "bill's", "coop", "cannot", "billet", "can't", "con", "bills", "co-op"
};
Console.WriteLine("Before sorting:");
foreach (string word in wordList)
{
Console.WriteLine(word);
}
Console.WriteLine(Environment.NewLine + "After sorting with CompareOptions.None:");
SortAndDisplay(wordList, CompareOptions.None);
Console.WriteLine(Environment.NewLine + "After sorting with CompareOptions.StringSort:");
SortAndDisplay(wordList, CompareOptions.StringSort);
}
// Sort the list of words with the supplied CompareOptions.
private static void SortAndDisplay(List<string> unsorted, CompareOptions options)
{
// Create a copy of the original list to sort.
var words = new List<string>(unsorted);
// Define the CompareInfo to use to compare strings.
CompareInfo comparer = CultureInfo.InvariantCulture.CompareInfo;
// Sort the copy with the supplied CompareOptions then display.
words.Sort((str1, str2) => comparer.Compare(str1, str2, options));
foreach (string word in words)
{
Console.WriteLine(word);
}
}
}
/*
CompareOptions.None and CompareOptions.StringSort provide identical ordering by default
in .NET 5 and later. But in prior versions, the output is the following:
Before sorting:
cant
bill's
coop
cannot
billet
can't
con
bills
co-op
After sorting with CompareOptions.None:
billet
bills
bill's
cannot
cant
can't
con
coop
co-op
After sorting with CompareOptions.StringSort:
bill's
billet
bills
can't
cannot
cant
co-op
con
coop
*/
module compareoptions_stringsort
open System
open System.Collections.Generic
open System.Globalization
let sortAndDisplay (unsorted: List<string>) (options: CompareOptions) =
let words = new List<string>(unsorted)
let comparer = CultureInfo.InvariantCulture.CompareInfo
words.Sort((fun str1 str2 -> comparer.Compare(str1, str2, options)))
for word in words do
printfn "%s" word
[<EntryPoint>]
let main argv =
let wordList = new List<string>(
["cant"; "bill's"; "coop"; "cannot"; "billet"; "can't"; "con"; "bills"; "co-op"])
printfn "Before sorting:"
for word in wordList do
printfn "%s" word
printfn "\nAfter sorting with CompareOptions.None:"
sortAndDisplay wordList CompareOptions.None
printfn "\nAfter sorting with CompareOptions.StringSort:"
sortAndDisplay wordList CompareOptions.StringSort
0 // return an integer exit code
(*
CompareOptions.None and CompareOptions.StringSort provide identical ordering by default
in .NET 5 and later, but in prior versions, the output will be the following:
Before sorting:
cant
bill's
coop
cannot
billet
can't
con
bills
co-op
After sorting with CompareOptions.None:
billet
bills
bill's
cannot
cant
can't
con
coop
co-op
After sorting with CompareOptions.StringSort:
bill's
billet
bills
can't
cannot
cant
co-op
con
coop
*)
Imports System
Imports System.Collections.Generic
Imports System.Globalization
Public Class StringSort
Public Shared Sub Main()
Dim wordList As New List(Of String) From {
"cant", "bill's", "coop", "cannot", "billet", "can't", "con", "bills", "co-op"
}
Console.WriteLine("Before sorting:")
For Each word In wordList
Console.WriteLine(word)
Next
Console.WriteLine(Environment.NewLine & "After sorting with CompareOptions.None:")
SortAndDisplay(wordList, CompareOptions.None)
Console.WriteLine(Environment.NewLine & "After sorting with CompareOptions.StringSort:")
SortAndDisplay(wordList, CompareOptions.StringSort)
End Sub
' Sort the list of words with the supplied CompareOptions.
Private Shared Sub SortAndDisplay(unsorted As List(Of String), options As CompareOptions)
' Create a copy of the original list to sort.
Dim words As New List(Of String)(unsorted)
' Define the CompareInfo to use to compare strings.
Dim comparer As CompareInfo = CultureInfo.InvariantCulture.CompareInfo
' Sort the copy with the supplied CompareOptions then display.
words.Sort(Function(str1, str2) comparer.Compare(str1, str2, options))
For Each word In words
Console.WriteLine(word)
Next
End Sub
End Class
' CompareOptions.None and CompareOptions.StringSort provide identical ordering by default
' in .NET 5 And later, but in prior versions, the output is the following:
'
'Before sorting
'cant
'bill's
'coop
'cannot
'billet
'can't
'con
'bills
'co-op
'After sorting with CompareOptions.None
'billet
'bills
'bill's
'cannot
'cant
'can't
'con
'coop
'co-op
'After sorting with CompareOptions.StringSort
'bill's
'billet
'bills
'can't
'cannot
'cant
'co-op
'con
'coop
Poznámky
V .NET 5 a novějších se pro zpracování řetězců používá knihovna ICU (International Components for Unicode) pro různé platformy. Knihovna ICU přináší následující změny chování porovnání řetězců:
- Výchozí možnost
Noneje ekvivalentní tétoStringSortmožnosti. Předchozí funkceNone, kde stejné váhy byly dány alfanumerické a nonalphanumeric znaky, již není k dispozici. - Ligatury (kombinované znaky jako "æ" a "æ") jsou ve výchozím nastavení v porovnání řetězců považovány za odlišné od jejich rozbalených formulářů ("ae", "oe"). Pokud chcete zacházet s ligaturami a jejich rozšířenými formuláři jako ekvivalentními, použijte tuto
IgnoreNonSpacemožnost.
Další informace o změně, včetně postupu obnovení předchozí obslužné rutiny Unicode, najdete v tématu .NET globalizace a ICU.
Možnosti CompareOptions označují citlivost písmen nebo nutnost ignorovat typy znaků.
.NET používá tři různé způsoby řazení: řazení slov, řazení řetězců a řadové řazení. Řazení textu provádí porovnání řetězců s ohledem na kulturní rozdíly. Některé nealfanumerické znaky mohou mít přiřazeny speciální váhy. Například spojovník ("-") může mít přiřazenou velmi malou váhu, aby se vedle sebe zobrazovaly "coop" a "co-op" v seřazeném seznamu. Řazení řetězců je podobné řazení slov s tím rozdílem, že neexistují žádné zvláštní případy. Proto všechny nealfanumerické znaky přicházejí před všechny alfanumerické znaky. Řadové řazení porovnává řetězce na základě hodnot Unicode každého prvku řetězce. Informace o sadě textových souborů, které obsahují informace o hmotnosti znaků použitých při operacích řazení a porovnání v operačních systémech Windows, naleznete v tématu Tabulky hmotnosti pro řazení. Tabulku hmotnosti řazení pro Linux a macOS najdete v tabulce výchozích prvků kolace unicode. Konkrétní verze tabulky priorit řazení v Linuxu a macOS závisí na verzi knihoven International Components for Unicode nainstalovaných na systému. Informace o verzích ICU a verzích Unicode, které implementují, naleznete v oddílu Stažení ICU.
Hodnotu StringSort lze použít pouze s CompareInfo.Compare a CompareInfo.GetSortKey.
ArgumentException je vyvolán, pokud je hodnota StringSort použita s CompareInfo.IsPrefix, CompareInfo.IsSuffix, CompareInfo.IndexOfnebo CompareInfo.LastIndexOf.
Note
Pokud je to možné, měli byste použít metody porovnání řetězců, které přijímají CompareOptions hodnotu k určení druhu očekávaného porovnání. Obecně platí, že porovnání z pohledu uživatele je nejlépe provádět pomocí jazykových voleb (s použitím aktuální kultury), zatímco porovnání zabezpečení by mělo specifikovat Ordinal nebo OrdinalIgnoreCase.
Řazení citlivá na kulturní specifika
Note
.NET Core spuštěný jenom v systémech Linux a macOS: Chování kolace pro kultury jazyka C a Posix je vždy citlivé na velikost písmen, protože tyto kultury nepoužívají očekávané Unicode pořadí kolace. Doporučujeme použít jinou jazykovou verzi než jazyk C nebo Posix pro provádění operací řazení nerozlišující malá a velká písmena.