C# Dictionary with two Values per Key?

前端 未结 10 1303
被撕碎了的回忆
被撕碎了的回忆 2020-12-13 17:36

I have a situation in code where a Dictionary seemed like the best idea - I need a collection of these objects and I need them to be acces

10条回答
  •  -上瘾入骨i
    2020-12-13 17:49

    A Dictionary is just a keyed collection of objects. As such, it will hold any type of object you want. Even the simplest of objects, like, say, an array (which derives from Object), but requires a lot less code on your behalf.

    Rather than writing an entire class, stuff a dynamically allocated array, or a List in the value and run with that.

    Dictionaries are highly flexible that way.

提交回复
热议问题