I want to get all classes from namespace so I have used this code:
var theList = Assembly.GetExecutingAssembly().GetTypes()
.Where(t => t.Namespace == myNameSpace)
.ToList();
It's working but when I'm looping through this list, I want to create instance or call constructor of each class in theList list and for example call their methods or properties.
Ofc this code is not working, but this is my purpose.
foreach (Type t in theList)
{
description += t.Description;
}
@Edit I did:
var theList = Assembly.GetExecutingAssembly().GetTypes()
.Where(t => t.Namespace == myNameSpace)
.ToList();
foreach (Type t in theList)
{
Command instance = (Command)Activator.CreateInstance(t);
result += Environment.NewLine + instance.Name + " - " + instance.Description;
}