How to use a strongly typed dictionary <string, Type> to associate a string with a class
4 answers
.Net has a dedicated class System.Typeused to describe classes / structures / enumerations (of any type) in the system. Dog- this is the class you want to get this information about, in order to get it, you can either get it using only Type, using typeof(Dog), or - if you have an instance Dog, you can usemyDog.GetType();
+4
typeof, Type:
public Dictionary<String, Type> dic = new Dictionary<String, Type>();
dic.Add("dog", typeof(Dog));
+10