I have a comboBox at my Form. When i'm pressing it, list of the names of the classes popped up. And when i'm choosing some name of the class there, i want to create object of that class and then work with it.
All my classes have a common parent, so i used this code to get all my sub classes:
var subclassTypes = Assembly
.GetAssembly(typeof(ParentClass))
.GetTypes()
.Where(t => t.IsSubclassOf(typeof(ParentClass)));
So after that i just added this to ComboBox, and its's work okay, it's showing all the classes i need in string. But how can i make an accordance between string name of the class and class itself? How can i store that accordance and how can i make it?
Type.Name,Type.FullNamein order to get name of the type?Dictionary<string, Type>if you want to store the corrspondence?