If all your jobs are of the same type (e.g. Job<string> ), you can simply create a list of this type:
List<Job<string>> x = new List<Job<string>>(); x.Add(new Job<string>());
However, if you want to mix jobs of different types (for example, Job<string> and Job<int> ) in the same list, you will have to create a base class or interface that is not shared:
public abstract class Job {
And then you can do:
List<Job> x = new List<Job>(); x.Add(new Job<string>());
If you want to get the Job type at runtime, you can do this:
Type jobType = x[0].GetType(); // Job<string> Type paramType = jobType .GetGenericArguments()[0]; // string
pswg
source share