NOTE: this question is subtly different than the potential duplicate ... and this has answers that work - read both before voting please :) .
--
We have two dictionaries that have a common base type for the value:
Here is the Code:
// Three classes
class BaseClass {...}
class Foo : BaseClass {...}
class Bar : BaseClass {...}
// Two collections
var fooDict = new Dictionary<long, Foo>;
var barDict = new Dictionary<long, Bar>;
// One method
public void FooBar (Dictionary<long, BaseClass> dict) {...}
// These do not work
FooBar(fooDict);
FooBar(barDict);
Is there a way for inheritance to work in a dictionary, or do we have to use a different paradigm - or am I just being stupid?
Any help or guidance with this would be appreciated.
Thank you in advance.