Select key and return value OR select value and return key
I imagine there is a very concise way to do this, but I'm new to .NET. I
have a bunch of pairs for a mapping. The mapping works both ways though.
I'd like to store them once, like this:
{"a", "a'"},
{"b", "b'"},
...
using a Dictionary or something. I know I can use linq to easily query a
dictionary, but how can I conditionally have it return the key if I query
a value or return the value if I input a key? For example, if input b',
output b. If input a, output a'.
The data structure does not have to be a dictionary by the way. I just
want the most concise way to store it and the most concise way to retrieve
it. This is not performance intensive.
No comments:
Post a Comment