Answers for "get set dictionary c#"

C#
5

get set c#

private string name;
public string Name
{
    get
    {
        return this.name;
    }
    set
    {
        this.name = value;
    }
}
Posted by: Guest on June-15-2020
0

can a dictionary type use get set c#

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; }
    }
}
Posted by: Guest on July-13-2021

C# Answers by Framework

Browse Popular Code Answers by Language