c# - 投 listView.SelectedIndices 到 List<int>

标签 c# listview casting

有没有什么办法投listView.SelectedIndicesList<int> ?
我试过了

(List<int>)reListViewAllMovies.SelectedIndices.Cast<List<int>>()

但它不起作用(InvalidCastException)。
如果解决方案不存在,是否有任何“单行”解决方案,例如使用 lambda 表达式?

最佳答案

老问题,但我一直在寻找解决方案。 .NET v4.5。我不知道该框架的早期版本。

var list = myListView.SelectedIndices.Cast<int>().ToList();

关于c# - 投 listView.SelectedIndices 到 List<int>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14046120/

相关文章:

c# - 无法将 NULL 值插入表的列 'ID'

c# - 我的 CPU 支持多少内存?

c# - 如何自动添加当前程序集中的所有 EntityTypeConfiguration<>?

javascript - react-native limit 列表项

Android ListAdapter 没有更新

android - 在具有不同单元格高度的 ListView 中滚动

scala - 在 scala 中将 Int 添加到字符串

java - 使用泛型多个边界的未经检查/未经确认的强制转换

c# - 静态函数需要锁定机制?

c - 在为副本进行转换后,我是否需要再次对 void 指针进行类型转换以进行算术?