Can I Create a Dictionary of Generic Types?

前端 未结 10 2450
误落风尘
误落风尘 2020-11-30 02:53

I\'d like to create a Dictionary object, with string Keys, holding values which are of a generic type. I imagine that it would look something like this:

Dict         


        
10条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-30 03:18

    Other posibility it's to use the variable dynamic.

    For example:

    Dictionary> d = new Dictionary>(); d.Add("Key", new List());

    the variable dynamic resolve the type on runtime.

提交回复
热议问题