C# How to make public getters and setters and private methods for a collection?

后端 未结 4 1644
谎友^
谎友^ 2021-02-04 21:50

I\'d like to have a class \"A\" with a (for example) SortedList collection \"SrtdLst\" property, and inside this class \"A\" allow the addition or subtraction of \"SrtdLst\" ite

4条回答
  •  眼角桃花
    2021-02-04 22:54

    If the keys are known outside of the class then you can add a ChangeItem(key, newValue) and ReadItem(key) to your wrapper class. Then keep the SortedList private to the class.

提交回复
热议问题