我有一个列表,其中包含已转换为字符串的字符串和整数。我正在尝试编写一个LINQ查询,其中包含不是整数的所有不同字符串的计数,例如“你好”,“你好‘问候’等,而且所有整数的计数但ARENT字符串,例如LINQ查询以仅计算某些值
List x = { "1", "6", "3", "Hi", "5", "Hello", "Hi" }
输出为:
integer count = 4
Hi = 2
Hello = 1
我目前拥有的查询把所有的arent整数然而正确每个整数被distinctinvely列出例如
您好计数= 2 你好计数= 1 1计数= 1 6计数= 1 3计数= 1 5计数= 1
这里是我的查询到目前为止:-(
var q = from x in output
group x by x into g
let count = g.Count()
orderby count descending
select new { Value = g.Key, Count = count };
我想有另一个循环计数的arent所有值嗨你好等
var integerCount = q.Select(
x => x.Value != "Hi"
|| x.Value != "Hello")
.Count();
但是这个数字似乎是不正确的。有无论如何,我可以做只返回我想要的1查询?
谢谢。