public string SetPreference(string UserName, string PreferenceName, string Value) { Dictionary <string, Dictionary <string, string> > preferences = new Dictionary <string, Dictionary <string, string> >(); Dictionary <string, string> NameValuePair; // Does the user have preferences defined? if (_Preferences.TryGetValue(UserName, out NameValuePair)) { // If so, is there an entry for this preference name? if (NameValuePair.ContainsKey(PreferenceName)) { NameValuePair[PreferenceName] = Value; } else { // no entry for this preference name // Add an entry for this preference name NameValuePair.Add(PreferenceName, Value); } _Preferences[UserName] = NameValuePair; } else { // no preference yet for this user // Add user and preference NameValuePair = new Dictionary <string, string>(); NameValuePair.Add(PreferenceName, Value); _Preferences.Add(UserName, NameValuePair); } return(NO_ERROR); }