I have a set of string that I need to store in a set, such as:
id, firstname, lastname, city, country, language
All of the above apply to a single person (represented by the ID)
Now I have 60 – 70 of these (and growing), how could I organize them? I have looked at the NameValueCollection class – and it does exactly what I want (if I only had two fields), but since I have 6 fields, I can’t use it. E.g.:
public NameValueCollection personCollection = new NameValueCollection
{
{ "harry", "townsend", "london", "UK", "english" },
{ "john", "cowen", "liverpool", "UK", "english" },
// and so on...
};
Although this does not work 🙁 Could someone suggest another way of achieving this?
If you absolutely don’t want to create any new classes, you could use a dictionary of lists, keyed by your ID:
…which you could then access using dictionary and list indexers:
However, the correct OOP approach would be to define a class with properties for your respective strings:
You could then create a list of persons: