I have a generic class and I want to create a list of it. and then at run time I get the type of the item
public class Job
{
pub
By making an interface and implement it in your class you will be able to create a list of that interface type,adding any job :
interface IJob
{
//add some functionality if needed
}
public class Job : IJob
{
public int ID { get; set; }
public Task Task { get; set; }
public TimeSpan Interval { get; set; }
public bool Repeat { get; set; }
public DateTimeOffset NextExecutionTime { get; set; }
public Job RunOnceAt(DateTimeOffset executionTime)
{
NextExecutionTime = executionTime;
Repeat = false;
return this;
}
}
List x = new List();
x.Add(new Job());