首页 > 解决方案 > 使用三元运算符的 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] 而不是元素名称

标签: c#linq

解决方案


我试过了,它奏效了

string Text = List.Any(x => x.IsnonConcurrent) ? coverage.Quotes
            .Where(x=>Number == quote.Number).Description + Details : coverage.Description + Details;

推荐阅读