How do you define a getter and setter for complex data types such as a dictionary?
public Dictionary Users
{
get
{
retu
Use an indexer property (MSDN):
public class YourClass
{
private readonly IDictionary _yourDictionary = new Dictionary();
public string this[string key]
{
// returns value if exists
get { return _yourDictionary[key]; }
// updates if exists, adds if doesn't exist
set { _yourDictionary[key] = value; }
}
}
Then use like:
var test = new YourClass();
test["Item1"] = "Value1";