.NET Dictionary as a Property

后端 未结 8 639
-上瘾入骨i
-上瘾入骨i 2021-02-02 08:30

Can someone point me out to some C# code examples or provide some code, where a Dictionary has been used as a property for a Class.

The examples I have seen so far don\'

8条回答
  •  别跟我提以往
    2021-02-02 09:24

    An example...

    public class Example
    {
        public Dictionary DictionaryProperty
        {
            get; set;
        }
    
        public Example()
        {
            DictionaryProperty = new Dictionary();
        }
    }
    
    public class MainForm
    {
        public MainForm()
        {
            Example e = new Example();
    
            e.DictionaryProperty.Add(1, "Hello");
            e.DictionaryProperty.Remove(1);
        }
    }
    

提交回复
热议问题