1
I am working on a tool where the user inserts information and based on some calculations in the entered value it returns a fixed value description.
Example:
User enters the value 101.
It value will be calculated based on some rules.
This value for example fits in Group A the final result after the calculation is 3 (We can have several groups A, B, C, D, E, F, G and so on...), and for each group I have some values already pre-defined.
Group A:
0 = inappropriate definition
1 = accepts all type of request
2 = awaiting validation
3 = status ok
I was storing these Values in Dictionary. Is there a simpler solution for me to take these guys dynamically or feed the Dictionary dynamically and then consume them ?
I thought of saving in a file . txt and mount the dictionary.
txt file.
A;0;Initial Status
A;1; Failure to boot
A;2;Failure to close
A;3;Status OK
Z;10; Error in memory
Z;24;Incorrect attempt
Z;54;Corrupted
Z;55;Indefinite status
Cool Edney, Today I’m populating Dictionary. Is there any way I can do this dynamically ? Because this Dictionary to be created it needs the Group after the key and value. Ie I am creating 1 dictionary for each group. I wanted to have only one dictionary and after calculating and identifying the group I would assemble that dictionary, based on some text file or json or something else. I don’t know how to proceed.
– lcs
Your question is a little hard to understand but I kick (based on what you wrote) that you need a : Dictionary<int, Dictionary<int, Object>. Then you can use with: values[i][j]. Edit your question and put more details, otherwise it is difficult...
– user178974
Also, you can use a Struct as a key (with the group and value), so you will only have a dictionary. Recommended you make Struct immutable to use as dictionary key (with private fields and pass parameters in constructor).
– user178974
I edited the question, I thought, save in a txt all the details of the messages and the groups and then mount in the dictionary Dictionary<string, Dictionary<int, string>>
– lcs
If it is too much data (but not too much) can use an Sqlite, does not depend on server, and is very efficient.
– user178974