I have an interface that requires the square brackets operator to be implemented. The class that inherits from this implements it. However,it also inherits from Dictionary<>, where that same operator is implemented:
public interface IFoo
{
IBar this[String tFooName] { get; }
}
[Serializable]
public class ConcreteFoo: Dictionary<String, Bar>, IFoo
{
// Implement interface by calling the dictionary
public IBar this[String tFooName] { get { return this[tFooName]; } }
// .... more code ....
}
When I try to use the code, the compiler references the immediate interface that was implemented and says that I cannot assign to it:
MyClass[tKeyStr] = new Bar();
The error is correct. So, I removed my implementation of the IFoo interface and hoped that by inheriting from Dictionary<>, it would be auto-implemented. It has not panned out the way I wanted.
I get the error 'does not implement interface member ...'.
How would I solve this without making the dictionary a private member?? Is there a way?