Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

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.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6240953
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T11:40:01+00:00 2026-05-24T11:40:01+00:00

I”ve got a List<Foo> . Foo class contains a Type property. Type property is

  • 0

I”ve got a List<Foo>. Foo class contains a Type property. Type property is a enum.

  public enum Type
  {
       Arithmetic, Fraction, ...
  }


  public class Foo
  {
      public Type ProblemType
      {
          get; set;
      }
  }

I’d like to generate another list where it is sorted by ProblemType, and each one contains Foo clases which belong to the same Type. I can imagine I should use Enumerable, but I don’t know how use them.

Thanks in advance

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T11:40:01+00:00Added an answer on May 24, 2026 at 11:40 am

    You can use GroupBy() to do that:

    List<List<Foo>> groupedLists
        = yourList.GroupBy(foo => foo.ProblemType)
                  .OrderBy(group => group.Key)
                  .Select(group => group.ToList())
                  .ToList();
    

    In passing, I would advise against using Type as the name of your enum, as getting into name conflicts with System.Type is usually not a good idea. You can even name it ProblemType, since writing public ProblemType ProblemType { get; set; } is unambiguous.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've got a string that has curly quotes in it. I'd like to replace
I'm looking for a way to convert text like this: <!DOCTYPE html PUBLIC \-//W3C//DTD
So I've got various reports that consist of a DataSet rendered in a Tablix...
I don't get it. I have two activities in which i parse an XML-file
A little encoding puzzle for you. A comment on a SourceForge tracker item contains
I want to show a progress bar in my activity which contains code to
I've got a mass of values in a JSON file containing the names of
I'm completely new to socket programming with C#, I'm trying to get two running
I have just tried to save a simple *.rtf file with some websites and
According to the WordPress wiki pages on developing themes, I have to call wp_head()

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.