LINQ Select Syntax VB.NET

一曲冷凌霜 提交于 2021-02-16 15:59:34

问题


I have a list of Tuples I am trying to run a Select and Where query on to return a list of Objects from the Tuple.Item5 parameter. In my where clause I am looking to match Tuple.Item4 to a local variable.

I'm not sure what the VB.NET syntax is for the Select portion, I only know the c# syntax.

Essentially I am trying to select Tuple.Item5 from my list of tuples where Tuple.Item4 = sCurID. I'm unsure as to what should go in the Select section although in c# I believe it would be Select(t => t.Item5)

This is what I have:

listObj = listTuples.Select( Unsure What Goes Here ).Where(Function(w) w.Item4 = sCurID)

回答1:


Once you apply the Select in C# or VB, you have reduced the Tuple to the Item5 value and can't access Item4. Do the Select last:

Dim listObj = listTuples.Where(Function(t) t.Item4 = sCurId).Select(Function(t) t.Item5)



回答2:


listObj = listTuples.Select(Function(t) t.Item5).Where(Function(w) w.Item4 = sCurID).ToList()


来源:https://stackoverflow.com/questions/45467568/linq-select-syntax-vb-net

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!