I have a generic class of
public class Mapper<K, L, V> : Dictionary<K, V>
When I instantiate it as
Mapper<string, string, MapSource> Map= new Mapper<string, string, MapSource>();
and try and do
Map["..."].
is comes back with compiler error message of
The call is ambiguous between the following methods or properties: ‘MinorTesting.XML.Sourcer.Mapper.this[L]’ and ‘MinorTesting.XML.Sourcer.Mapper.this[K]’
How would I fix this to remove the compile .
Bob.
What does
MultiKeyDictionarylook like and where/how is it used?It looks like
MultiKeyDictionaryprovides two indexers,this[L]andthis[K]. WhenLandKare the same then the compiler is unable to choose between those indexers because they’ve effectively both becomethis[string].One option would be to provide explicit methods to use in place of the indexer in this case: for example,
GetByKey(K)andGetByValue(L)or similar.