Skip to content

Children<TNode>.FirstOfTypeOrDefault Method ​

Definition ​

Returns the first node in the collection of the specified type or a specified default if it doesn't contain any nodes of the specified type.

c#
public TChild? FirstOfTypeOrDefault<TChild>(TChild? @default = null)
   where TChild : TNode;

View source

Type Parameters ​

NameDescription
TChildThe type of the node to return.

Parameters ​

NameTypeDescription
defaultTChildThe default value to return if the collection does not contain any nodes of type TChild.

Returns ​

TChild

The first node if it is of the specified type or default if it doesn't contain any nodes of the specified type.