2014-07-24 213 views
0

在vb.net中在以下代码中使用Items.Remove和Items.RemoveAt有什么区别?从VB中删除项目

If lstCountries.SelectedIndex <> -1 Then 
     lstCountries.Items.RemoveAt(lstCountries.SelectedIndex) 
    End If 
+0

http://stackoverflow.com/questions/3211679/is-it-faster-the-listt-removet-or-listt-removeatint-method – HengChin

+3

当你把鼠标放在单词上时,你的VS是否告诉你它的区别?由Intellisense提供?不是你的VS有对象浏览器(查看菜单 - >对象浏览器)给你任何你想要的定义? – Plutonix

回答

2

的“RemoveAt移除”通过指数至极除去identifys单个对象但使用的“删除”,可以删除任何对象simlar在参数至极给出的一个装置,如果存在具有相同propreyties一个确切的对象它也可以删除

0

removeAt以index作为参数,同时删除take item作为参数。 RemoveAt更快,因为它直接处理索引并执行操作,同时删除检查所有索引以查找匹配的项目。