I\'d like to create a Dictionary object, with string Keys, holding values which are of a generic type. I imagine that it would look something like this:
Dict
Would something like this work?
public class GenericDictionary
{
private Dictionary _dict = new Dictionary();
public void Add(string key, T value) where T : class
{
_dict.Add(key, value);
}
public T GetValue(string key) where T : class
{
return _dict[key] as T;
}
}
Basically it wraps all the casting behind the scenes for you.