I have a method that is designed to accept a List in it's declaration as follows:
public class MyHandler
{
public T LookUp<T>()
{
//This method compiles and returns a dynamically typed List
...
}
}
I call this method from elsewhere as such:
MyHandler mh = new MyHandler();
List<AgeGroup> ageGroups = mh.LookUp<List<AgeGroup>>();
This process works great, but I am looking for a way of being able to dynamically load the AgeGroup type from a string.
I have found examples like this, but am not able to work out how to implement it in this case. For example, I have tried the following (and does not compile):
Type t = Assembly.Load("MyNamespace").GetType("MyNamespace.AgeGroup");
List<t> ageGroups = mh.LookUp<List<t>>();
I also tried using typeof(t), but to no avail. Any ideas?