我有一个通用类,我想创建一个列表。然后在运行时我得到项目的类型
班级
public class Job<T>
{
public int ID { get; set; }
public Task<T> Task { get; set; }
public TimeSpan Interval { get; set; }
public bool Repeat { get; set; }
public DateTimeOffset NextExecutionTime { get; set; }
public Job<T> RunOnceAt(DateTimeOffset executionTime)
{
NextExecutionTime = executionTime;
Repeat = false;
return this;
}
}
我想要达到的目标
List<Job<T>> x = new List<Job<T>>();
public void Example()
{
//Adding a job
x.Add(new Job<string>());
//The i want to retreive a job from the list and get it's type at run time
}