ObjectExtensionsInT(T, ReadOnlySpanT) Method

Gets whether item is among the elements of set.
See the Examples section of the InT(T, T) overload for an example.

Definition

Namespace: KGySoft.CoreLibraries
Assembly: KGySoft.CoreLibraries (in KGySoft.CoreLibraries.dll) Version: 8.0.0
C#
public static bool In<T>(
	this T item,
	ReadOnlySpan<T> set
)

Parameters

item  T
The item to search for in set.
set  ReadOnlySpanT
The set of items in which to search the specified item.

Type Parameters

T
The type of item and the set elements.

Return Value

Boolean
if item is among the elements of set; otherwise, .

Usage Note

In Visual Basic and C#, you can call this method as an instance method on any object of type T. When you use instance method syntax to call this method, omit the first parameter. For more information, see Extension Methods (Visual Basic) or Extension Methods (C# Programming Guide).

Remarks

This method works similarly to the in operator in SQL and Pascal.

This overload uses generic IEqualityComparerT implementations to compare the items for the best performance.

  Note

If elements of set are complex expressions consider to use the InT(T, FuncT) overload instead to prevent evaluating all elements until they are actually compared.

See Also