Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
所以我在列表中有一些对象。我想让我的对象有一个方法,当被调用时会从列表中删除自己。我怎么能那样做?
这是一个技巧问题吗?
public class MyObject { public void RemoveFromList(List<MyObject> list) { if (list == null) return; list.Remove(this); } }