Table of Contents

Method TryGetFirstValueWhere

Namespace
DisCatSharp.Common
Assembly
DisCatSharp.Common.dll

TryGetFirstValueWhere<TSource>(List<TSource?>?, Func<TSource?, bool>, out TSource?)

Safely tries to get the first match out of a list.

public static bool TryGetFirstValueWhere<TSource>(this List<TSource?>? list, Func<TSource?, bool> predicate, out TSource? value)

Parameters

list List<TSource>

The list to use.

predicate Func<TSource, bool>

The predicate.

value TSource

The value to get if succeeded

Returns

bool

Whether a value was found.

Type Parameters

TSource

Value type of list.