i want to create instance of any class by generic way. is that possible?i know ,this is madly but this is only a question waits the its answer.
i tried this but doesnt work.
public class blabla {
public void bla();
}
public class Foo<T>
{
Dictionary<string, Func<object>> factory;
public Foo()
{
factory = new Dictionary<string, Func<object>>();
}
public WrapMe(string key)
{
factory.Add(key, () => new T());
}
}
Foo<blabla> foo = new Foo<blabla>();
foo.Wrapme("myBlabla");
var instance = foo.factory["myBlabla"];
instance.Bla();