I want to create a dictionary to associate a string to a class for example:
"dog" -> Dog class
"cat" -> Cat class
so I tried this
public Dictionary<String, Type> dic = new Dictionary<String, Type>();
dic.Add("dog", Dog);
but Add doesn’t accept Dog.
So what’s the syntax ?
In .Net there is a dedicated class,
System.Type, used to describe classes/structures/enums (any type) in the system.Dogis the class you want this info about, to get it you can either retrieve it using just theTypeby usingtypeof(Dog), or–if you have an instance ofDogyou can usemyDog.GetType();