识别列表中的对象得到更新 [英] Identifying a object inside a list get updated

查看:53
本文介绍了识别列表中的对象得到更新的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,

我有一个这样的对象列表.

列表< items> lstItems;

在启动时,此列表可以包含一些项目.在运行时,用户可以从该列表中添加/删除项目.然后,如何得知用户已更改项目列表而不更改列表计数..

Hi All,

I have a list of objects like this.

List<items> lstItems;

At the startup this list can have some items. In run time user can add/remove items from this list. Then how can I get know user has change the item list without reffering to the list count..

推荐答案

实施 ^ ]可能对您有用.
Implementing http://msdn.microsoft.com/en-us/library/system.collections.specialized.inotifycollectionchanged.aspx[^] may be useful to you.


只需使用布尔标志isChanged.更改列表时,请设置值.
另一种方法是在启动时创建列表的副本,然后比较两个列表.
Just use a boolean flag isChanged. Set the value whenever you are changing the list.
The other way is to create a copy of list at startup, and compare both lists.


这篇关于识别列表中的对象得到更新的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆