add items of subclasses to a dictionary that expects a baseclass

vongst

New Member
\[code\]dictionary<string,BaseClass> Foo =new dictionary<string,BaseClass>();Foo.Add("Item1" , new SubClass());\[/code\]but this is not working ? how to handle this ?Update : errors are \[code\]cannot convert from 'BaseClass' to 'SubClass'The best overloaded method match for 'System.Collections.Generic.Dictionary<string,BaseClass>.Add(string, BaseClass)' has some invalid arguments \[/code\]
 
Back
Top