Generic and non Generic compare : Generic Method : Generic C# Examples


C# Examples » Generic » Generic Method »

 

Generic and non Generic compare









    
using  System;
using  System.Collections;
using  System.Collections.Generic;

public  class  MainClass
{

        public  void  NonGeneric(  Stack  stack  )  {
                foreach(  object  o  in  stack  )  {
                        int  number  =  (int)  o;
                        Console.WriteLine(  number  );
                }
        }

        public  void  Generic(  Stack<int>  stack  )  {
                foreach(  int  number  in  stack  )  {
                        Console.WriteLine(  number  );
                }
        }
}
    
   
  
   




HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Generic
» Generic Method