Q:

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.

A:

The most concise way is the use a Dictionary and put everything in it, for example:
{ "a", "a'" }
{ "a'", "a" }
{ "b", "b'" }
{ "b'", "b" }

Lookup and usage would be fast and clear

A:

Create a dictionary extension method.
public static string Retrieve(this Dictionary<string,string> dictionary, string value)
    {
        var item = (from v in dictionary
                    where v.Key == value || v.Value == value
                    select (v.Key == value) ? v.Value : v.Key
                    ).FirstOrDefault();

        return item;
    }

