How to handle add to list event?

后端 未结 10 2375
伪装坚强ぢ
伪装坚强ぢ 2020-11-29 22:55

I have a list like this:

List list = new List

How to handle adding new position to this list?

When

10条回答
  •  执念已碎
    2020-11-29 23:29

    One simple solution is to introduce an Add method for the list in your project and handle the event there. It doesn't answer the need for an event handler but can be useful for some small projects.

    AddToList(item) // or
    AddTo(list,item)
    ////////////////////////
    
    void AddTo(list,item)
    {
        list.Add(item);
        // event handling
    }
    

    instead of

    list.Add(item);
    

提交回复
热议问题