![]() |
Stack represents a last-in, first out collection of object. It is used when you need a last-in, first-out access of items. When you add an item in the list, it is called pushing the item and when you remove it, it is called popping the item. Stack<T>.ToArray Method is used to copy a Stack<T> to a new array. Properties:
Syntax: public T[] ToArray (); Return Type: This method returns a new array t[] which contains the copy of the elements of the Stack<T>. Below given are some examples to understand the implementation in a better way : Example 1:
Output:
GeeksforGeeks Data Structures Noida Geeks Classes Geeks Example 2:
Output:
6 5 4 3 2 Reference: |
Reffered: https://www.geeksforgeeks.org
C# |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 9 |