How do I override List's Add method in C#?

后端 未结 10 1313
名媛妹妹
名媛妹妹 2020-11-27 18:59

I am currently looking to make my own collection, which would be just like a regular list, except that it would only hold 10 items. If an item was added when there were alre

10条回答
  •  我在风中等你
    2020-11-27 19:35

    You can try to extend System.Collections.ObjectModel.Collection, which is much more flexible. You can then override the protected members InsertItem and SetItem, to customize the behaviour of your collection.

提交回复
热议问题