If it exists, what is the C# equivalent of the following Java code:
new HashMap, Integer>();
I currently
Was looking into this same problem and this poor man's checker is the best thing I could come up with:
class MyValue {
public Type Type { get; private set; }
private MyValue(Type type)
{
this.Type = type;
}
public MyValue of() where T : BaseClass
{
return new MyValue(typeof(T));
}
}
IDictionary myDictionary = new Dictionary()
{
{ 1, MyValue.of(); },
{ 2, MyValue.of(); },
{ 3, MyValue.of(); }, // this causes a compile error
};