Skip to content

Children<TNode>.LastIfTypeOrDefault Method ​

Definition ​

Returns the last node in the collection if it is of the specified type or a specified default if the collection is empty or the last node is a different type.

c#
public TChild? LastIfTypeOrDefault<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 is empty or the last node is not of type TChild.

Returns ​

TChild

The last node if it is of the specified type or default otherwise.

Remarks ​

Slightly quicker than LastOfTypeOrDefault<TChild>(TChild) if you only care about the last node.