Push and pop value in a generic Stack : Generic Stack : Generic C# Examples


C# Examples » Generic » Generic Stack »

 

Push and pop value in a generic Stack









    
using  System;    
using  System.Collections.Generic;    
      
class  MainClass  {    
    public  static  void  Main()  {    
        Stack<string>  st  =  new  Stack<string>();    
    
        st.Push("One");    
        st.Push("Two");    
        st.Push("Three");    
        st.Push("Four");    
        st.Push("Five");    
  
        while(st.Count  >  0)  {  
            string  str  =  st.Pop();  
            Console.Write(str  +  "  ");  
        }  
  
        Console.WriteLine();    
    }    
}
    
   
  
   



Output

Five Four Three Two One


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Generic
» Generic Stack