Skip to content

Instantly share code, notes, and snippets.

@matarillo
Created September 2, 2014 03:30
Show Gist options
  • Save matarillo/abb0a27a0f4bee7b34f2 to your computer and use it in GitHub Desktop.
Save matarillo/abb0a27a0f4bee7b34f2 to your computer and use it in GitHub Desktop.

型変数の部分適用のC#版

というほど大げさな話ではなく

public class Key<TKey>
{
    public Dictionary<TKey, TValue> CreateDictionary<TValue>()
    {
        return new Dictionary<TKey, TValue>();
    }
}

var key = new Key<string>();
var dictionary = key.CreateDictionary<int>();

で良かったりしませんかね。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment