>If(T == type of(MyClass)) >{ >This.Data.Add( new T() >{ >// and depending on my class I populate different properties here. >}); >else >{ > // and so on >} > >If you're not using generics would something like this work:
public class XlToList { private readonly Type _t; public XlToList(Type t) { _t = t; Data = new List<ITarriffDataImport>(); } public List<ITarriffDataImport> Data { get; set; } public void Process() { Data.Add((ITarriffDataImport) Activator.CreateInstance(_t)); } } //With: var xlListClass = new XlToList(typeof(MyClass)); xlListClass.Process();