ObjectExtensionsInT(T, FuncT) Method

Gets whether item is among the results of set.

Definition

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

Parameters

item  T
The item to search for in the results of set.
set  FuncT
The set of delegates, whose results are checked whether they are equal to the specified item.

Type Parameters

T
The type of item and the set elements.

Return Value

Boolean
if item is among the results 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. The elements of set are evaluated only when they are actually compared so if a result is found the rest of the elements will not be evaluated.

  Note

If elements of set are constants or simple expressions consider to use the InT(T, T) overload to eliminate the overhead of delegate invokes.

See Also