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.
The following code snippet displays the use of the Stack class:

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:



Other articles

Click here to Article home

 
uCertify.com | Our Company | Articles | Privacy | Security | Contact Us
MCSE: MCSA, MCTS, MCITP    JAVA Certification: SCJP, SCWCD Cisco Certification: CCNA, CCENT, A+, Network+, Security+
Oracle Certification: OCP 9i, OCP 10g, OCA 9i, OCA 10g CIW foundation    EC-212-32    CISSP    Photoshop ACE    Adobe Flash ACE
© 2008 uCertify.com. All rights reserved. All trademarks are the property of their respective owners.