c# - 如何在ListView c#上显示列表中大于1的所有数字
问题描述
我想在 ListView 的列表中显示所有大于 1 的数字
foreach (var item2 in listAlert)
{
int maxAlertt = item2.levelForecast;
item2.levelForecast = Math.Max(maxAlertt, maxAlertt);
lstLevel2.ItemsSource = listAlert;
}
listAlert
有整数 1,2,3,4 的数据我只想显示 2,3 和 4 in lstLevel2
.
怎么做 ?
解决方案
您可以使用 LINQ 查询来执行此操作 - 您不需要foreach
循环
lstLevel2.ItemsSource = listAlert.Where(x => x.SomeProperty > SomeValue).ToList();
推荐阅读
- airflow - 如何经济高效地配置 Google Cloud Composer
- c# - Umbraco 媒体通过 Cloudinary
- ios - URLSession datatask在Swift4.2/iOS12中返回0字节数据
- angular - Firestore 更新数组中的特定元素
- javascript - 如何在打字稿中将对象推入数组对象?
- c# - MongoDB C#:无法从 BsonType 'DateTime' 反序列化 'String'
- c# - 获取表格中的先前列表和总天数
- batch-file - 使用批处理修改 .properties 文件中的字符串
- php - 在后台运行的 PHP 脚本不起作用
- javascript - JS Fetch 绕过 http/s 要求