I want to make a dictionary that stores some values I want to use within my code. Would it be better to use an instance variable to hold the dictionary, or an XML file to hold the dictionary, or perhaps another way of storing the dictionary? The dictionary currently has 15 elements and I am constantly extending it.
-
3Questions that include terms like "better" must also state your specific criteria for being "better," without resorting to tautologies like "best practice."– Robert HarveyCommented Jul 24, 2017 at 15:42
-
XML is an exchange file format. You cannot use that within your program. But you can employ a library to create C# classes from an XSD and fill them with the XML file content.– Timothy TruckleCommented Jul 24, 2017 at 15:43
-
do you mean load the values from an xml file when you start the program? I think it will depend on how you are using the values– EwanCommented Jul 24, 2017 at 16:19
-
@RobertHarvey thanks, I meant as a software developer what would make it most convenient for other people to read them?– Mohamed MoselhyCommented Jul 24, 2017 at 19:38
Add a comment
|
1 Answer
So you read the file when the application starts to hold settings?
I would use XML as I think it is easier to serialize to disk.
You can write a wrapper so it behave like a Dictionary.
With only 15 items you are not going to have speed issues.