c# - 使用三元运算符的 LINQ 选择查询
问题描述
根据以下条件,我无法从列表中获取特定元素,有人可以在这里帮助我吗
string Text = List.Any(x => x.IsnonConcurrent) ? coverage.Quotes
.Where(x=>Number == quote.Number).Select(x=>quote.Description)
.ToList()
.ToString() + Details : coverage.Description + Details;
我在输出中看到 SYSTEM.COLLECTIONS.GENERIC.LIST`1[SYSTEM.STRING] 而不是元素名称
解决方案
我试过了,它奏效了
string Text = List.Any(x => x.IsnonConcurrent) ? coverage.Quotes
.Where(x=>Number == quote.Number).Description + Details : coverage.Description + Details;
推荐阅读
- r - R:循环仅输出最后一次迭代
- python - 如何在 Python 中使用 argparse 模块处理参数逻辑
- javascript - 为什么这个 React Hooks 组件中的状态没有更新?
- node.js - POST 请求在 Chrome 上返回 405(不允许的方法)
- java - 如何让函数在调用自身之前等待
- python - 如何使用“子进程”模块从 Python 脚本调用 R 脚本?
- binding - 如何在 SwiftUI 中绑定计算属性
- rest - Spring Boot 在运行时操作 http 参数
- excel - 如何使用 vba 将大型 Excel 表格粘贴到多张幻灯片中?
- python - 带有 matplotlib.dates(和 datestr2num)的绘图刻度中的日期格式问题