The ToArray method is used to create an array and copy the stack elements to it, then the array is passed to the Stack constructor that takes IEnumerable, creating a copy of the stack with the order of the elements reversed. The Peek method is used to look at the next item on the stack, and then the Pop method is used to pop it off. The Pop method is used to pop the first string off the stack. The elements of the stack are enumerated, which does not change the state of the stack. The code example creates a stack of strings with default capacity and uses the Push method to push five strings onto the stack. The following code example demonstrates several methods of the Stack generic class. IEnumerable IReadOnl圜ollection ICollection IEnumerable Examples Implements ICollection, IEnumerable(Of T) Type Parameters Implements ICollection, IEnumerable(Of T), IReadOnl圜ollection(Of T) Public Class Stack(Of T) Interface IEnumerable Public Class Stack(Of T) Interface IReadOnl圜ollection type Stack = class Public class Stack :, 圜ollection, public class Stack :, type Stack = class Public ref class Stack : System::Collections::Generic::IEnumerable, System::Collections::ICollection public class Stack :, 圜ollection, Public ref class Stack : System::Collections::Generic::IEnumerable, System::Collections::Generic::IReadOnl圜ollection, System::Collections::ICollection generic Represents a variable size last-in-first-out (LIFO) collection of instances of the same specified type.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |