我想要一个字典,其中值是通用对象,并且对于字典中的每个值都不相同.怎么能这样做,我觉得我错过了一些简单的事情.
例如
public interface IMyMainInterface
{
Dictionary<string, IMyInterface<T>> Parameters { get; }
}
public interface IMyInterface<T>
{
T Value
{
get;
set;
}
void SomeFunction();
}
Result:
dic.Add("key1", new MyVal<string>());
dic.Add("key2", new MyVal<int>());
Run Code Online (Sandbox Code Playgroud)