Arpit Khandelwal
Arpit Khandelwal

Reputation: 1803

How to store a matrix of values in C#?

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 boolean value, I pass Mode, Code, Priority and Name and my datastructure returns the boolean.

Any suggestions?

Upvotes: 1

Views: 1245

Answers (2)

AK_
AK_

Reputation: 8099

Option 1: Dictionary<Name,MagicalClass>

Option 2: [int][int]

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

Upvotes: 1

templatetypedef
templatetypedef

Reputation: 372814

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.

Upvotes: 1

Related Questions