Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
49 changes: 22 additions & 27 deletions xml/System.Globalization/CompareOptions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -75,38 +75,33 @@
Defines the string comparison options to use with <see cref="T:System.Globalization.CompareInfo" />.
</summary>
<remarks>
<format type="text/markdown">
<![CDATA[
In .NET 5 and later, the cross-platform ICU (International Components for Unicode) library is used for string processing. The ICU library brings the following changes to string comparison behavior:
<format type="text/markdown"><![CDATA[

- The default option `None` is now equivalent to the `StringSort` option. The previous functionality of `None`, where equal weighting was given to alphanumeric and nonalphanumeric characters, is no longer available.
- Ligatures (combined characters like "æ" and "œ") are now seen as distinct from their expanded forms ("ae", "oe") in string comparisons by default. To treat ligatures and their expanded forms as equivalent, use the `IgnoreNonSpace` option.
In .NET 5 and later, the cross-platform ICU (International Components for Unicode) library is used for string processing. The ICU library brings the following changes to string comparison behavior:

For more information about the change, including how to restore the previous Unicode handler, see [.NET globalization and ICU](/dotnet/core/extensions/globalization-icu).
- The default option `None` is now equivalent to the `StringSort` option. The previous functionality of `None`, where equal weighting was given to alphanumeric and nonalphanumeric characters, is no longer available.
- Ligatures (combined characters like "æ" and "œ") are now seen as distinct from their expanded forms ("ae", "oe") in string comparisons by default. To treat ligatures and their expanded forms as equivalent, use the `IgnoreNonSpace` option.

For more information about the change, including how to restore the previous Unicode handler, see [.NET globalization and ICU](/dotnet/core/extensions/globalization-icu).

For more information about this API, see [Supplemental API remarks for CompareOptions](/dotnet/fundamentals/runtime-libraries/system-globalization-compareoptions).

## Examples

The following code example shows how each of the CompareOptions values affect string comparisons.

:::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareOptions/Overview/compareoptions_values.cs" interactive="try-dotnet":::
:::code language="fsharp" source="~/snippets/fsharp/System.Globalization/compareoptions_values.fs":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareOptions.Values/VB/compareoptions_values.vb":::

The following code example shows how sorting with StringSort differs from sorting without StringSort.

:::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareOptions/Overview/compareoptions_stringsort.cs" interactive="try-dotnet":::
:::code language="fsharp" source="~/snippets/fsharp/System.Globalization/compareoptions_stringsort.fs":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareOptions.StringSort/VB/compareoptions_stringsort.vb":::

For more information about this API, see [Supplemental API remarks for CompareOptions](/dotnet/fundamentals/runtime-libraries/system-globalization-compareoptions).
]]></format>
</remarks>
<example>
The following code example shows how each of the CompareOptions values affect string comparisons.
<format type="text/markdown">
<![CDATA[
:::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareOptions/Overview/compareoptions_values.cs" interactive="try-dotnet":::
:::code language="fsharp" source="~/snippets/fsharp/System.Globalization/compareoptions_values.fs":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareOptions.Values/VB/compareoptions_values.vb" id="Snippet1":::
]]>
</format>
</example>
<example>
The following code example shows how sorting with StringSort differs from sorting without StringSort.
<format type="text/markdown">
<![CDATA[
:::code language="csharp" source="~/snippets/csharp/System.Globalization/CompareOptions/Overview/compareoptions_stringsort.cs" interactive="try-dotnet":::
:::code language="fsharp" source="~/snippets/fsharp/System.Globalization/compareoptions_stringsort.fs":::
:::code language="vb" source="~/snippets/visualbasic/VS_Snippets_CLR_System/system.Globalization.CompareOptions.StringSort/VB/compareoptions_stringsort.vb" id="Snippet2":::
]]>
</format>
</example>
<related type="Article" href="/dotnet/standard/base-types/basic-string-operations">Basic String Operations in .NET</related>
</Docs>
<Members>
Expand Down