Create and use a generic Dictionary : Generic Dictionary : Generic C# Examples


C# Examples » Generic » Generic Dictionary »

 

Create and use a generic Dictionary









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



class  MainClass
{
        public  static  void  Main(string[]  args)
        {
                Dictionary<string,MyClass>  MyClassDictionary  =  new  Dictionary<string,MyClass>();

                MyClassDictionary.Add("Crypto",  new  MyClass());

                MyClass  myClass  =  MyClassDictionary["Crypto"];

                Console.WriteLine("Got  from  dictionary:  {0}",  myClass);



        }
}
class  MyClass  {
        
      public  override  string  ToString(){
        
            return  "my  class";
      }
        
}
    
   
  
   



Output

Got from dictionary: my class


HTML code for linking to this page:

Follow Navioo On Twitter

C# Examples

 Navioo Generic
» Generic Dictionary