Use generic list to store your own class : Generic List : Generic C# Examples


C# Examples » Generic » Generic List »

 

Use generic list to store your own class









    
using  System.Collections.Generic;
using  System;


class  MainClass
{
        public  static  void  Main(string[]  args)
        {

                List<MyClass>  list  =  new  List<MyClass>();

                list.Add(new  MyClass());

                MyClass  ass2  =  list[0];

                Console.WriteLine("\nFound  in  list:  {0}",  ass2);
        }
}
class  MyClass  {
        
      public  override  string  ToString(){
        
            return  "my  class";
      }
        
}
    
   
  
   



Output

Found in list: my class


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Generic
» Generic List