小弟我想把ListBox的SelectedObjectCollection和ObjectCollection作为参数传递,函数参数如何定义
我想把ListBox的SelectedObjectCollection和ObjectCollection作为参数传递,函数参数怎么定义?
我想把ListBox的SelectedObjectCollection和ObjectCollection作为参数传递,函数参数怎么写可以同时传递这两种变量?
private int Add(SelectedObjectCollection lists)
private int Add(ObjectCollection lists)
把这两个函数弄成一个
------解决方案--------------------
他两个不都继承自IList ,应该可以通过 as 转换的吧
------解决方案--------------------
foreach需要的支持IEnumerable的类,恰巧SelectedObjectCollection和ObjectCollection都支持IEnumerable,所以方法签名可改为private int Add(IEnumerable lists)
我想把ListBox的SelectedObjectCollection和ObjectCollection作为参数传递,函数参数怎么写可以同时传递这两种变量?
private int Add(SelectedObjectCollection lists)
private int Add(ObjectCollection lists)
把这两个函数弄成一个
------解决方案--------------------
他两个不都继承自IList ,应该可以通过 as 转换的吧
------解决方案--------------------
foreach需要的支持IEnumerable的类,恰巧SelectedObjectCollection和ObjectCollection都支持IEnumerable,所以方法签名可改为private int Add(IEnumerable lists)