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 7520099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:00:32+00:00 2026-05-30T02:00:32+00:00

I have this following class: public class TV { public string GroupId { get;

  • 0

I have this following class:

public class TV
{
    public string GroupId { get; set; }
    public string Title { get; set; }
    public string Genre { get; set; }
}

Then I have this following list (which is dynamic created and will never be same):

List<TV> myList = new List<TV>();
myList.Add(new TV { GroupId = "1", Title = "Title 1", Genre = "Genre A" });
myList.Add(new TV { GroupId = "1", Title = "Title 2", Genre = "Genre A" });
myList.Add(new TV { GroupId = "1", Title = "Title 3", Genre = "Genre A" });
myList.Add(new TV { GroupId = "3", Title = "Title 4", Genre = "Genre 18" });
myList.Add(new TV { GroupId = "A", Title = "Title 5", Genre = "Genre 18" });
myList.Add(new TV { GroupId = "A", Title = "Title 6", Genre = "Genre A" });
myList.Add(new TV { GroupId = "B", Title = "Title 7", Genre = "Genre A" });
myList.Add(new TV { GroupId = "C", Title = "Title 8", Genre = "Genre A" });
myList.Add(new TV { GroupId = "D", Title = "Title 9", Genre = "Genre 18" });
myList.Add(new TV { GroupId = "D", Title = "Title 10", Genre = "Genre A" });
myList.Add(new TV { GroupId = "D", Title = "Title 11", Genre = "Genre A" });
myList.Add(new TV { GroupId = "E", Title = "Title 12", Genre = "Genre A" });

I have the following (hardcoded) navigation categories that are links:

[0-9] [ABC] [DEF] [GHI] [JKL] [MNO] [PQR] [STU] [VWXYZ]

I’m trying to loop myList and by looking at the GroupId property, I want to place it in the appropriate div so I end up having divs like this:

<div id="group-09">
<div>
    1, Title 1, Genre A
    1, Title 2, Genre A
    1, Title 3, Genre A
    3, Title 4, Genre 18
</div>
</div>

<div id="group-ABC">
<div>
    A, Title 5, Genre 18
    A, Title 6, Genre A
    B, Title 7, Genre A
    C, Title 8, Genre A
</div>
</div>

<div id="group-DEF">
<div>
    D, Title 9, Genre 18
    D, Title 10, Genre A
    D, Title 11, Genre A
    E, Title 12, Genre A
</div>
</div>

I can’t seem to figure out the logic to properly do this!
Does anyone have a suggestion?
Thanks

  • 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-30T02:00:33+00:00Added an answer on May 30, 2026 at 2:00 am

    You can create a dictionary that maps GroupIds to <div> ids and group the items in myList by <div> id:

    var groups = new Dictionary<string, string>
    {
        { "0", "group-09" },
        { "1", "group-09" },
        { "2", "group-09" },
        ...
        { "A", "group-ABC" },
        ...
    };
    
    var query = from item in myList
                group item by groups[item.GroupId];
    
    foreach (var group in query)
    {
        Console.WriteLine("id: " + group.Key);
        foreach (var item in group)
        {
            Console.WriteLine("       " + item.Title);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this following structure: public class Dummy { public string Name { get;
I have the following class: public class ExternalClass { public string Name {get;set;} public
Say I have the following class: public MainFormViewModel { public String StatusText {get; set;}
I have the following class: public class Category { public string Name { get;
I have the following class: public class Topic { public string Topic { get;
Have the following: class Hal { public int zip { get; set; } public
I have the following class: public class MySeat { public string Section { get;
I have the following class: public class Test { public string Text { get;
I have the following class hierarchy class Test { public string Name { get;
I have the following class: public class Person { public String Name { get;

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.