How do I create a Dictionary that holds different types in C#

前端 未结 8 436
庸人自扰
庸人自扰 2020-12-04 21:38

I need some sort of way to store key/value pairs where the value can be of different types.

So I like to do:

 int i = 12;
 string s = \"test\";
 doub         


        
8条回答
  •  星月不相逢
    2020-12-04 22:05

    Dictionary is clearly the quickest solution.

    Another way could be to store a custom class in which you could store the actual value and the information regarding its type

提交回复
热议问题