在列表框中添加项目 [英] Adding Items In Listbox

查看:117
本文介绍了在列表框中添加项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我继续循环添加列表框中的项目达1个或更多,则继续
在一段时间后,列表框是否有可能变为空
那是
listbox1 = null是否可以?

记住我不清除listbox中的项目.

If i keep on adding items in listbox in a loop for 1 or more than of that continuesly
is it possible that after some perticular period of time listbox may become null
that is
listbox1 = null is it possible ?

remember i dont clear items from listbox

推荐答案

请稍等.

如果将null分配给引用类型的任何变量,则对对象本身不做任何事情.您修改此变量(或某个类或结构的成员)的值,但这仅是对此对象的引用.但是,结果,对象可能会失去可达性. CLR可以确定无法从执行代码中的任何位置访问该对象.并且在这种情况下,对象可以被垃圾收集器(i)破坏-请在此处查看有关可达性和垃圾收集的信息:
http://en.wikipedia.org/wiki/Garbage_collector_%28computing%29 [ ^ ].

考虑一下.我觉得您缺少一些非常基本和重要的内容.

现在,这与列表框中的项目无关.例如,可以使用方法Clear删除这些项目.

—SA
Wait a second.

If you assign null to any variable of a reference type, you don''t do anything to the object itself. You modify the value of this variable (or a member of some class or structure), but this is only a reference to this object. However, as a result, the object may loose reachability. The CLR can figure out that the object cannot be accessed from anywhere in the executing code; and in this case the object can be destructed by the Garbage Collector (GC) — please see about reachability and garbage collection here:
http://en.wikipedia.org/wiki/Garbage_collector_%28computing%29[^].

Just think about it. I feel you are missing something very basic and important.

Now, this all has nothing to do with items in the list box. The items can be removed, for example, by the method Clear.

—SA


是的,可以放入列表框的项目数是有限制的.当然,编写一个只向列表框添加空字符串却什么也不做的程序是很荒谬的.
Yes there is a limit to the number of items that you can stuff into a listbox. Of course, writing a program that does nothing but add an empty string to a listbox is pretty much nonsensical.


这篇关于在列表框中添加项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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