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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T23:55:06+00:00 2026-06-11T23:55:06+00:00

My scenario : I have an object, lets call it object1 which looks like

  • 0

My scenario :

I have an object, lets call it object1 which looks like this :

object1{
string commaSeparatedListOfIds;
DateTime time;
int passes;
...
irrelvant properties
...
}

What I wish to do is split commaSeparatedListOfIds for each id value, and save each one in it’s own object (object2), with the relevant other properties.

object2{
int id;
DateTime time;
int passes;
}

This duplicates information, but for the method I want to write any other solution will be horrifically messy.

What I have tried is :

 List<object2> newObjects = new List<object2>(object1.commaSeparatedListOfIds.Split(',').Select(
                        new object2{
                        id int.Parse,
                        time = object1.time
                        passes = object1.passes
                        }).ToList<object2>());

but this will not build.

Can anyone help me do what I wish as elegantly as possible please ? I realise it would be possible with two loops and some horrible code, but I know there’s a nice looking solution out there somewhere! 🙂

  • 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-06-11T23:55:07+00:00Added an answer on June 11, 2026 at 11:55 pm

    I believe you want something like:

     List<object2> newObjects = object1.commaSeparatedListOfIds.Split(',')
                                       .Select(str =>
                                            new object2
                                            {  
                                               id = int.Parse(str),
                                               time = object1.time,
                                               passes = object1.passes
                                            })
                                       .ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Consider this scenario. I have an object, lets call it.... Foo. Foo raises a
I have an object in C# like this: private ClassWidget { public int ID;
Lets say I have a custom data type that looks something like this: public
Following scenario: I have user object: ... @Column(name = TITLE) private String title; @NotNull
In my app, I have this scenario where I need to post an object
It looks like #temptables created using dynamic SQL via the EXECUTE string method have
lets begin with the scenario: I have an ItemsControl inside a UserControl. In this
I came across this scenario. We have a class lets say Main having a
Consider this scenario we have a class A which is singleton it has a
Here is the scenario: I have an object called a Transaction that needs to

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.