![](/img/trans.png)
[英]How to create dynamic Multiple And linq conditions in foreach loop
[英]Conditions on foreach loop using Linq
我有一個List<KeyValuePair<string, Records> mylist;
我想在列表中循環查看每個不同的鍵值。 就像是
foreach(var item in myList.select(/\*query the disctinct values of key here ?*/)
可能嗎 ? 怎么樣 ?
你可以做
foreach(var item in myList.Select(x => x.Key).Distinct())
{
//Your Logic
}
myList.Select(x => x.Key).Distinct()
將為您提供不同的鍵,並且foreach
將遍歷它們。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.