現在、TKey でソートされた双方向ルックアップ アソシエーション ジェネリックに取り組んでいます。ある時点で、次のようなアクセスができることを願っています。
public class Assoc<TKey, TValue>
{
public TKey this[TValue value] { get; }
public TValue this[TKey value] { get; }
}
しかし、明らかに TKey == TValue の場合、これは失敗します。好奇心から、これを行うための条件付きコンパイル構文はありますか:
public class Assoc<TKey, TValue>
{
[Condition(!(TKey is TValue))]
public TKey this[TValue value] { get; }
[Condition(!(TKey is TValue))]
public TValue this[TKey value] { get; }
public TKey Key(TValue value) { get; }
public TValue Value(TKey value) { get; }
}