I am trying to create an object pool which will have objects of diffrent types.
Will it be possible , If i passed a string as ps a parameter to RetriveFunction();
it should rturn a new object of string type or feth it from pool?
string will contain name of type.
Eg;
Object RetriveFromPool(string typename)
{
if()//object does not present
{
//return new object of typename
}
else
{
//feth it from pool
}
}
will it be possible?
Yes, this is possible. A Dictionary is a convenient way to store key value pairs with O(1) lookup and
Activatoris capable of instantiating a type known only at runtime:As an alternate however (to ensure compile time type checking) you may wish to use generics to achieve this: