Skip to main content
Tab

Collection<T>.Find(Predicate<T>) Method

Returns the first element that matches the conditions defined by the specified predicate.

Namespace: DevExpress.Web

Assembly: DevExpress.Web.v24.1.dll

NuGet Package: DevExpress.Web

Declaration

public T Find(
    Predicate<T> match
)

Parameters

Name Type Description
match Predicate<T>

A delegate that defines the conditions of the elements to search for.

Returns

Type Description
T

The element that matches the conditions defined by the predicate.

Remarks

The Find method individually passes elements of the current collection to a predicate, and returns the first element that matches the predicate. A predicate is a delegate to a method that returns true if the object passed to it matches the conditions defined in the delegate; otherwise the method returns false.

Example

The code sample below demonstrates how to obtain a navigation bar group that is currently expanded. For this purpose, the Find method is used. The IsExpanded predicate determines whether a group is expanded.

using DevExpress.Web.ASPxNavBar;
...
NavBarGroup ExpandedGroup = ASPxNavBar1.Groups.Find(IsExpanded);
...
private static bool IsExpanded(NavBarGroup group) {
     return group.Expanded;
}
See Also