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. |
The object at the top of the stack without moving it, or a default value if the stack is empty.
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. |
The object at the top of the stack without moving it, or a default value if the stack is empty.