I have a case Sensitive dictionary,
Dictionary<string, uint> itemNames = new Dictionary<string, uint>(StringComparer.Ordinal);
So I can have case sensitive keys in this dictionary.
For example I can have below key value pairs,
- { test, 10 }
- { TEST, 20 }
- { test1, 30 }
- { test2, 40 }
...
When someone passes key, I want to retrieve the value. The retrieval should be partially case insensitive which means, If exact case is matched then return the case sensitive result, if case sensitive key doesn't exists then retrieve case insensitive key value.
For example, with the above values inserted in the dictionary
If user passes key as "TEST" I need to return 20.
If user passes key as "TEST1" , the case sensitive key is not found so I need to return 30.
How to achieve this in C# ?