Can I Create a Dictionary of Generic Types?

前端 未结 10 2453
误落风尘
误落风尘 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条回答
  •  忘掉有多难
    2020-11-30 03:38

    One of the way is to create a Dictionary value with type "object" like:

    Dictionary d = new Dictionary();

    So, here object datatype is used as a generic datatype, you can put anything in this as a value.

提交回复
热议问题