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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:36:50+00:00 2026-05-23T03:36:50+00:00

How to create a complex object from a list of fields ex.: public class

  • 0

How to create a “complex” object from a list of fields

ex.:

public class Lines {
  public string itemName;
  public string locationName;
  public string locationGeo;

}

List<Lines> lines = new List<Lines>(){
    new Lines() {itemName= "item1", locationName="someloc1", locationGeo="1.11, 1.11"},
    new Lines() {itemName= "item1", locationName="someloc2", locationGeo="1.12, 1.12"},
    new Lines() {itemName= "item1", locationName="someloc3", locationGeo="1.13, 1.13"},
    new Lines() {itemName= "item2", locationName="someloc4", locationGeo="1.14, 1.14"},
    new Lines() {itemName= "item2", locationName="someloc5", locationGeo="1.15, 1.15"}
}

Group to something like, example object:

public class exampleLines{
    public string itemName;
    public locations locs;
}

ps.: this class doesn’t exist at all.

  • 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-23T03:36:51+00:00Added an answer on May 23, 2026 at 3:36 am

    So you want to group by itemName? Something like:

    var query = lines.GroupBy(x => x.itemName)
          .Select(g => new { ItemName = g.Key,
                             Locations = g.Select(x => new { Name = x.locationName,
                                                             Geo = x.locationGeo })
                                          .ToList() })
          .ToList();
    

    That’s got two anonymous types in – once for the “container” class, and once for the “location” part.

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

Sidebar

Related Questions

I am trying to create a quick hashcode function for a complex number class
I have a complex table pulled from a multi-ActiveRecord object array. This listing is
public class Car { public string SomeProperty { get; set; } public Manufacturer Manufacturer
If I have a complex object, can I inherit from it and remove or
I have a complex django object, which has properties of other class types. This
I would like to bind a complex object to a view. I create a
I'd like to create a fairly complex row in my UIPicker. All of the
I'm trying to create a somewhat complex sorting feature which neither uses divs nor
My situation is a bit complex. I want to create $config rules for my
I created the following function to simplify a piece of particularly complex code. CREATE

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.