Table of Contents

Class StackExtensions

Namespace
CarinaStudio.Collections
Assembly
CarinaStudio.AppBase.Core.dll

Extensions for Stack<T>.

public static class StackExtensions
Inheritance
StackExtensions
Inherited Members

Methods

IsEmpty<T>(Stack<T>)

Check whether the given stack is empty or not.

public static bool IsEmpty<T>(this Stack<T> stack)

Parameters

stack Stack<T>

Stack to check.

Returns

bool

True if the stack is empty.

Type Parameters

T

Type of element of stack.

Remarks

The method is available for target framework before .NET 9.

IsNotEmpty<T>(Stack<T>?)

Check whether the given stack is not empty or not.

public static bool IsNotEmpty<T>(this Stack<T>? stack)

Parameters

stack Stack<T>

Stack to check.

Returns

bool

True if the stack is not empty.

Type Parameters

T

Type of element of stack.

Remarks

The method is available for target framework before .NET 9.

IsNullOrEmpty<T>(Stack<T>?)

Check whether given stack is null/empty or not.

public static bool IsNullOrEmpty<T>(this Stack<T>? stack)

Parameters

stack Stack<T>

Stack to check.

Returns

bool

True if the stack is null or empty.

Type Parameters

T

Type of element of stack.

Remarks

The method is available for target framework before .NET 9.

TryPeek<T, TOut>(Stack<T>, out TOut)

Try peeking value in stack as given type.

public static bool TryPeek<T, TOut>(this Stack<T> stack, out TOut value) where TOut : T

Parameters

stack Stack<T>

Stack<T>.

value TOut

Peeked value.

Returns

bool

True if value peeked as given type successfully.

Type Parameters

T

Type of value in stack.

TOut

Desired type of value.

TryPop<T, TOut>(Stack<T>, out TOut)

Try popping value from stack as given type.

public static bool TryPop<T, TOut>(this Stack<T> stack, out TOut value) where TOut : T

Parameters

stack Stack<T>

Stack<T>.

value TOut

Popped value.

Returns

bool

True if value popped as given type successfully.

Type Parameters

T

Type of value in stack.

TOut

Desired type of value.