Skip to content

Commit 0d624cd

Browse files
authored
Update equals_ex3.cs (#7896)
1 parent bfceb6f commit 0d624cd

File tree

3 files changed

+59
-52
lines changed

3 files changed

+59
-52
lines changed

snippets/csharp/System/String/Equals/equals_ex3.cs

Lines changed: 57 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,9 @@ public class Example3
77
{
88
public static void Main()
99
{
10-
String[] cultureNames = { "en-US", "se-SE" };
11-
String[] strings1 = { "case", "encyclopædia",
12-
"encyclopædia", "Archæology" };
13-
String[] strings2 = { "Case", "encyclopaedia",
14-
"encyclopedia" , "ARCHÆOLOGY" };
10+
String[] cultureNames = { "en-US", "th-TH", "tr-TR" };
11+
String[] strings1 = { "a", "i", "case", };
12+
String[] strings2 = { "a-", "\u0130", "Case" };
1513
StringComparison[] comparisons = (StringComparison[])Enum.GetValues(typeof(StringComparison));
1614

1715
foreach (var cultureName in cultureNames)
@@ -33,61 +31,70 @@ public static void Main()
3331
}
3432
// The example displays the following output:
3533
// Current Culture: en-US
34+
// a = a- (CurrentCulture): False
35+
// a = a- (CurrentCultureIgnoreCase): False
36+
// a = a- (InvariantCulture): False
37+
// a = a- (InvariantCultureIgnoreCase): False
38+
// a = a- (Ordinal): False
39+
// a = a- (OrdinalIgnoreCase): False
40+
//
41+
// i = İ (CurrentCulture): False
42+
// i = İ (CurrentCultureIgnoreCase): False
43+
// i = İ (InvariantCulture): False
44+
// i = İ (InvariantCultureIgnoreCase): False
45+
// i = İ (Ordinal): False
46+
// i = İ (OrdinalIgnoreCase): False
47+
//
3648
// case = Case (CurrentCulture): False
3749
// case = Case (CurrentCultureIgnoreCase): True
3850
// case = Case (InvariantCulture): False
3951
// case = Case (InvariantCultureIgnoreCase): True
4052
// case = Case (Ordinal): False
4153
// case = Case (OrdinalIgnoreCase): True
42-
//
43-
// encyclopædia = encyclopaedia (CurrentCulture): True
44-
// encyclopædia = encyclopaedia (CurrentCultureIgnoreCase): True
45-
// encyclopædia = encyclopaedia (InvariantCulture): True
46-
// encyclopædia = encyclopaedia (InvariantCultureIgnoreCase): True
47-
// encyclopædia = encyclopaedia (Ordinal): False
48-
// encyclopædia = encyclopaedia (OrdinalIgnoreCase): False
49-
//
50-
// encyclopædia = encyclopedia (CurrentCulture): False
51-
// encyclopædia = encyclopedia (CurrentCultureIgnoreCase): False
52-
// encyclopædia = encyclopedia (InvariantCulture): False
53-
// encyclopædia = encyclopedia (InvariantCultureIgnoreCase): False
54-
// encyclopædia = encyclopedia (Ordinal): False
55-
// encyclopædia = encyclopedia (OrdinalIgnoreCase): False
56-
//
57-
// Archæology = ARCHÆOLOGY (CurrentCulture): False
58-
// Archæology = ARCHÆOLOGY (CurrentCultureIgnoreCase): True
59-
// Archæology = ARCHÆOLOGY (InvariantCulture): False
60-
// Archæology = ARCHÆOLOGY (InvariantCultureIgnoreCase): True
61-
// Archæology = ARCHÆOLOGY (Ordinal): False
62-
// Archæology = ARCHÆOLOGY (OrdinalIgnoreCase): True
63-
//
64-
//
65-
// Current Culture: se-SE
54+
//
55+
//
56+
// Current Culture: th-TH
57+
// a = a- (CurrentCulture): True
58+
// a = a- (CurrentCultureIgnoreCase): True
59+
// a = a- (InvariantCulture): False
60+
// a = a- (InvariantCultureIgnoreCase): False
61+
// a = a- (Ordinal): False
62+
// a = a- (OrdinalIgnoreCase): False
63+
//
64+
// i = İ (CurrentCulture): False
65+
// i = İ (CurrentCultureIgnoreCase): False
66+
// i = İ (InvariantCulture): False
67+
// i = İ (InvariantCultureIgnoreCase): False
68+
// i = İ (Ordinal): False
69+
// i = İ (OrdinalIgnoreCase): False
70+
//
71+
// case = Case (CurrentCulture): False
72+
// case = Case (CurrentCultureIgnoreCase): True
73+
// case = Case (InvariantCulture): False
74+
// case = Case (InvariantCultureIgnoreCase): True
75+
// case = Case (Ordinal): False
76+
// case = Case (OrdinalIgnoreCase): True
77+
//
78+
//
79+
// Current Culture: tr-TR
80+
// a = a- (CurrentCulture): False
81+
// a = a- (CurrentCultureIgnoreCase): False
82+
// a = a- (InvariantCulture): False
83+
// a = a- (InvariantCultureIgnoreCase): False
84+
// a = a- (Ordinal): False
85+
// a = a- (OrdinalIgnoreCase): False
86+
//
87+
// i = İ (CurrentCulture): False
88+
// i = İ (CurrentCultureIgnoreCase): True
89+
// i = İ (InvariantCulture): False
90+
// i = İ (InvariantCultureIgnoreCase): False
91+
// i = İ (Ordinal): False
92+
// i = İ (OrdinalIgnoreCase): False
93+
//
6694
// case = Case (CurrentCulture): False
6795
// case = Case (CurrentCultureIgnoreCase): True
6896
// case = Case (InvariantCulture): False
6997
// case = Case (InvariantCultureIgnoreCase): True
7098
// case = Case (Ordinal): False
7199
// case = Case (OrdinalIgnoreCase): True
72-
//
73-
// encyclopædia = encyclopaedia (CurrentCulture): False
74-
// encyclopædia = encyclopaedia (CurrentCultureIgnoreCase): False
75-
// encyclopædia = encyclopaedia (InvariantCulture): True
76-
// encyclopædia = encyclopaedia (InvariantCultureIgnoreCase): True
77-
// encyclopædia = encyclopaedia (Ordinal): False
78-
// encyclopædia = encyclopaedia (OrdinalIgnoreCase): False
79-
//
80-
// encyclopædia = encyclopedia (CurrentCulture): False
81-
// encyclopædia = encyclopedia (CurrentCultureIgnoreCase): False
82-
// encyclopædia = encyclopedia (InvariantCulture): False
83-
// encyclopædia = encyclopedia (InvariantCultureIgnoreCase): False
84-
// encyclopædia = encyclopedia (Ordinal): False
85-
// encyclopædia = encyclopedia (OrdinalIgnoreCase): False
86-
//
87-
// Archæology = ARCHÆOLOGY (CurrentCulture): False
88-
// Archæology = ARCHÆOLOGY (CurrentCultureIgnoreCase): True
89-
// Archæology = ARCHÆOLOGY (InvariantCulture): False
90-
// Archæology = ARCHÆOLOGY (InvariantCultureIgnoreCase): True
91-
// Archæology = ARCHÆOLOGY (Ordinal): False
92-
// Archæology = ARCHÆOLOGY (OrdinalIgnoreCase): True
93100
// </Snippet3>

xml/System/String.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5586,7 +5586,7 @@ Invalid sequences are represented in the enumeration by <xref:System.Text.Rune.R
55865586
The `comparisonType` parameter indicates whether the comparison should use the current or invariant culture, honor or ignore the case of the two strings being compared, or use word or ordinal sort rules.
55875587

55885588
## Examples
5589-
The following example compares four sets of words by using each member of the <xref:System.StringComparison> enumeration. The comparisons use the conventions of the English (United States) and Sami (Upper Sweden) cultures. Note that the strings "encyclopædia" and "encyclopaedia" are considered equivalent in the en-US culture but not in the Sami (Northern Sweden) culture.
5589+
The following example compares three sets of strings by using each member of the <xref:System.StringComparison> enumeration. The comparisons use the conventions of the English (United States), Thai (Thailand) and Turkish (Turkey) cultures. Note that the strings "a" and "a-" are considered equivalent in the "th-TH" culture but not in the others, while "i" and "İ" are considered equivalent in the "tr-TR" culture when case is ignored but not in the other cultures.
55905590

55915591
:::code language="csharp" source="~/snippets/csharp/System/String/Equals/equals_ex3.cs" interactive="try-dotnet" id="Snippet3":::
55925592
:::code language="fsharp" source="~/snippets/fsharp/System/String/Equals/equals_ex3.fs" id="Snippet3":::

xml/System/StringComparison.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@
6969
For more information about comparisons, see the <xref:System.String?displayProperty=nameWithType> class remarks. For more information about culture, see the <xref:System.Globalization.CultureInfo?displayProperty=nameWithType> class remarks. For guidelines on when to use ordinal or culture-sensitive comparison rules or the rules of the invariant culture, see [Best Practices for Using Strings](/dotnet/standard/base-types/best-practices-strings). For a set of text files that contain information on the character weights used in sorting and comparison operations for Windows operating systems, see [Sorting Weight Tables](https://www.microsoft.com/download/details.aspx?id=10921). For the sort weight table for Linux and macOS, see the [Default Unicode Collation Element Table](https://www.unicode.org/Public/UCA/latest/allkeys.txt).
7070
7171
## Examples
72-
The following example compares four sets of words by using each member of the <xref:System.StringComparison> enumeration. The comparisons use the conventions of the English (United States) and Sami, Northern (Sweden) cultures. Note that the strings "encyclopædia" and "encyclopedia" are considered equivalent in the en-US culture but not in the Sami, Northern (Sweden) culture.
72+
The following example compares three sets of strings by using each member of the <xref:System.StringComparison> enumeration. The comparisons use the conventions of the English (United States), Thai (Thailand), and Turkish (Turkey) cultures. Note that the strings "a" and "a-" are considered equivalent in the "th-TH" culture but not in the others, while "i" and "İ" are considered equivalent in the "tr-TR" culture when case is ignored but not in the other cultures.
7373
7474
:::code language="csharp" source="~/snippets/csharp/System/String/Equals/equals_ex3.cs" id="Snippet3":::
7575
:::code language="fsharp" source="~/snippets/fsharp/System/String/Equals/equals_ex3.fs" id="Snippet3":::

0 commit comments

Comments
 (0)