开发者

How to store a matrix of values in C#?

开发者 https://www.devze.com 2023-02-08 10:58 出处:网络
My requirement is to create a datastructure in which I can save boolean values based on a number of keys.

My requirement is to create a datastructure in which I can save boolean values based on a number of keys. for example:

     |Mode|Code|Priority|
Name1|    |    |        |
Name2|    |    |        |
Name3|    |    |        |
Name4|    |    |        |

So that whenever I need the boole开发者_StackOverflowan value, I pass Mode, Code, Priority and Name and my datastructure returns the boolean.

Any suggestions?


One option would be to use a Dictionary whose keys are a custom type encoding the mode, code, priority, and name and whose values are bools indicating the value you're storing. If your values are predominantly false, then you could instead use some sort of hash set that stores tuples associated with true where all values not present in the set are implicitly missing.


Option 1: Dictionary<Name,MagicalClass>

Option 2: [int][int]

But what you are looking for is clearly the Dictionary and not a matrix.

0

精彩评论

暂无评论...
验证码 换一张
取 消