>> public class AClass >> { >> private Dictionary<string, string> Tables_; >> private object TableLocker = new Object(); >> >> >> public Dictionary<string, string> Tables >> { >> get >> { >> lock (TableLocker) >> { >> return Tables_; >> } >> } >> private set >> { >> Tables_ = value; >> } >> } >> >> public void ReInitalizeTables() >> { >> lock (TableLocker) >> { >> Tables_ = new Dictionary<string, string>(); >> Tables_.Add("1", "one"); >> Tables_.Add("2", "two"); >> } >> } >> } >> >>>
public class AClass { private Dictionary<string, string> Tables_; public Dictionary<string, string> Tables { get; private set; } public AClass() { // Initialize Tables Tables_ = new Dictionary<string, string>(); Tables_.Add("1", "one"); Tables_.Add("2", "two"); } public void ReInitializeTables() { // do not set to null Dictionary<string, string> tmp = new Dictionary<string, string>(); tmp.Add("3", "three"); tmp.Add("4", "four"); Tables_ = tmp; } }