Enumerating the stack

PowerShell will display the content of a stack in the same way as it would the content of an array. It isn't possible to index into a stack. The ToArray() method may be used to convert the stack into an array if required:

$stack.ToArray() 

The preceding command returns an array of the same type as the stack. That is, if a stack is configured to hold strings, the array will be an array of strings.

The stack has a Peek method that allows retrieval of the top element from the stack without it being removed:

$stack.Peek() 

The Peek method will throw an error if the stack is empty (refer to the Removing elements from the stack section).

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.225.31.159