You can create an ApplictionSetting using the Visual Studio Designer of Type 'HashTable if you need to have several key-value pairs of Type 'string or any other Type.
1. go into your Project's Properties folder in the Property Broweser, and double-click Settings.Settings: this will bring up the Settings Designer.
2. create a new setting by clicking in one of the blank rows of the Settings display Grid.
3. click on the 'Type menu-option to open the Type Browser: click 'Browse: open mscorlib/Collections.Generic and selct 'HashTable.
4. Set the setting scope to 'User, and give the new Setting an appropriate name; we'll use "HashSetting" for this example (no quotes).
In code, to use the Hash Setting:
private Hashtable Hash;
private void btbAddToHash_Click(object sender, EventArgs e)
{
Hash = new Hashtable
{
{"string1", "outcome1"},
{"string2", "outcome2"}
};
Properties.Settings.Default.HashSetting = Hash;
Properties.Settings.Default.Save();
}
private string GetHashValue(string hashKey)
{
return (string) Properties.Settings.Default.Hash1[hashKey];
}
string test1 = (string)Properties.Settings.Default.Hash1["string1"];
string test2 = GetHashValue("string2");
Console.WriteLine("{0} : {1}", test1, test2);