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.

  • 3
    Questions that include terms like "better" must also state your specific criteria for being "better," without resorting to tautologies like "best practice." 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. 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
    – Ewan
    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? Jul 24, 2017 at 19:38

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.