TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Ab Laxman
NA
14
1.1k
Multi-parameter anonymous types?
Mar 1 2018 11:48 PM
I recenty stumbled upon a piece of LINQ code written below
var cons = xdoc.Descendants(
"xref"
)
.Where(x=>x.Attribute(
"rid"
).Value.Contains(
"ref"
))
.GroupBy(x=>x.Parent)
.Select(grp=>
new
{
Parent = grp.Key,
ConsecutiveNodes = grp.Select((n, i)=>
new
{
Index = i+1,
Node = n
}),
Count = grp.Count()
})
.ToList();
Now I cannot understand the part
.Select(grp=>
new
{
Parent = grp.Key,
ConsecutiveNodes = grp.Select((n, i)=>
new
{
Index = i+1,
Node = n
}),
Count = grp.Count()
})
Can anyone break it down for me because I cannot figure it out on my own, there are a lot of new things that I haven't seen before...like an anonymous type inside and anonymous type? and what is the
grp.Select((n, i)
thing? how does it work?
Reply
Answers (
1
)
How to insert table into word document in specific position.
Read MPP File in C#