StringComparer.IsWellKnownOrdinalComparer Method

Definition

Determines whether the specified IEqualityComparer<T> is a well-known ordinal string comparer.

public static bool IsWellKnownOrdinalComparer (System.Collections.Generic.IEqualityComparer<string?>? comparer, out bool ignoreCase);

Parameters

comparer
IEqualityComparer<String>

The comparer to query.

ignoreCase
Boolean

When this method returns, contains a value stating whether comparer is case-insensitive. Set to false if this method returns false.

Returns

true if comparer is a well-known ordinal string comparer; otherwise, false.

Remarks

A "well-known ordinal comparer" describes a comparer that behaves identically to Ordinal when passed to Dictionary<TKey,TValue> or HashSet<T>. For example, Default is a well-known ordinal comparer because a Dictionary<TKey,TValue> given Default as a constructor argument will behave identically to a Dictionary<TKey,TValue> given Ordinal as a constructor argument. If ignoreCase is true on method exit, then comparer behaves identically to OrdinalIgnoreCase when passed to the constructor of such a collection.

Applies to

产品 版本
.NET 6, 7, 8, 9