将ListBox.SelectedObjectCollection转换为ListBox.ObjectCollection? [英] Casting a ListBox.SelectedObjectCollection to a ListBox.ObjectCollection?

查看:511
本文介绍了将ListBox.SelectedObjectCollection转换为ListBox.ObjectCollection?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以将一个ListBox.SelectedObjectCollection转换为C#中的ListBox.ObjectCollection?

$ p

解决方案

我有一个函数接受 List< string> ;



我可以通过转换SelectedItem和Items来传递它们。

尝试此操作:

  SelectedItems.Cast< string>()ToList()
Items.Cast< string& ).ToList()

< string> 可以用一些其他对象类型替换。


Is it possible to cast a ListBox.SelectedObjectCollection to a ListBox.ObjectCollection in C#? If so, how would I go about it?

解决方案

I have a function that accepts List<string>.

I can pass both SelectedItems and Items by casting them.

Try this:

SelectedItems.Cast<string>().ToList()
Items.Cast<string>().ToList()

<string> could be replaced with some other object type.

这篇关于将ListBox.SelectedObjectCollection转换为ListBox.ObjectCollection?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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