Question: How do you define a getter and setter for complex data types such as a dictionary?

```
public Dictionary<string, string> Users
{
    get
    {
        return m_Users;
    }

    set
    {
        m_Users = value;
    }
}

```

This returns the entire dictionary? Can you write the setter to look and see if a specific key-value pair exists and then if it doesn't, add it. Else update the current key value pair? For the get, can you return a specific key-value pair instead of the whole dictionary?

Answer: 
Use an indexer property ([MSDN](http://msdn.microsoft.com/en-us/library/6x16t2tx.aspx)):

```
public class YourClass
{
    private readonly IDictionary<string, string> _yourDictionary = new Dictionary<string, string>();

    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";

```
```
Dictionary<string, string> param = new Dictionary<string, string>();

public void SetYourParameter(string parametrName, string paramValue)
{
    param[parametrName] = paramValue;            
}

public string GetYourParameter(string parametrName)
{
    // ContainKey ---> It returns value if the key was found
    if( param.ContainsKey(parametrName))
        return param[parametrName];
    else
        return null;
}

```