What is the Stack class?
Are you preparing for IT certification? With practice questions, study notes, interactive quizzes, tips and technical articles, uCertify PrepKits ensure that you get a solid grasp of core technical concepts to ace your certification exam in first attempt.
What is the Stack class?
Rating:
The Stack is a data structure that stores objects in such a manner that the object inserted last in the stack, is the first to come out. The Stack is also called, last in first out (LIFO) list. The two important methods used in the Stack class are as follows:
- Push(): It inserts an object into the Stack.
- Pop(): It removes an object from the Stack.
using System;
using System.Collections;
public class MyStackClass
{
public static void Main()
{
Stack mystack = new Stack();
mystack.Push("Microsoft");
mystack.Push("Corporation");
mystack.Push("Limited");
PrintTheValues(mystack);
}
public static void PrintTheValues(IEnumerable MyCollection)
{
foreach(Object list in MyCollection)
Console.Write(list);
}
}
Rating:
Was this information helpful?
Other articles
- What is the base keyword?
- What is the BitArray class?
- What is the params keyword?
- How to enumerate the logical drives?
- What is a nullable type?