suppose my list<struct>
in list some struct have the date 31 january
some have date 5 march
some have 12 august then
i want to make a list of all same date struct
how i can do this in c#
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Assume your struct looks like this:
Then you can use GroupBy to get the dates:
Group by groups on unique values, so you need to group on the Date property of the DateTime instance. The code above will return an
IEnumerable<IGrouping<DateTime>>, where the key of each group will be the corresponding date.