StackUtility.PeekOrDefault<T> method (1 of 2)

Returns the object at the top of the stack without moving it, or a default value if the stack is empty.

public static T? PeekOrDefault<T>(this Stack<T> stack)
parameter description
T The type of element on the stack.
stack The stack.

Return Value

The object at the top of the stack without moving it, or a default value if the stack is empty.

See Also


StackUtility.PeekOrDefault<T> method (2 of 2)

Returns the object at the top of the stack without moving it, or a default value if the stack is empty.

public static T? PeekOrDefault<T>(this Stack<T> stack, T? defaultValue)
parameter description
T The type of element on the stack.
stack The stack.
defaultValue The default value.

Return Value

The object at the top of the stack without moving it, or a default value if the stack is empty.

See Also