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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T05:59:09+00:00 2026-06-16T05:59:09+00:00

I have a C# List that I want to create a comma separate string.

  • 0

I have a C# List that I want to create a comma separate string. I’ve found other answers on SO that deal with this, but my particular case I want to only use a portion of the values in the List to create the string.

If my List contained these values:

“Foo”
“Bar”
“Car”

and I wanted to create a string

Foo, Bar and Car.

I could use this code:

string.Format("{0} and {1}.", 
              string.Join(", ", myList.Take(myList.Count - 1)), 
              myList.Last());

However, my list is actual formed of jSON values like so

{ Name = "Foo" }
{ Name = "Bar" }
{ Name = "Car" }

So the above code results in:

{ Name = "Foo" }, { Name = "Bar" } and { Name = "Car" }.

How would I construct the string such that I only use the Foo, Bar and Car values in the list?

Update

Thanks to @StevePy, this is what I ended up with:

string.Format("{0} and {1}.", 
              string.Join(", ", myList.Select(x => x.Name).ToList().Take(myList.Count - 1)), 
              myList.Select(x => x.Name).ToList().Last());
  • 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-16T05:59:10+00:00Added an answer on June 16, 2026 at 5:59 am

    Linq should help.

    var nameList = myList.Select(x=>x.Name).ToList();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a list of markers that I want to create a polygon around
I created the list that have device detected, and I want to send data
I have a list that I want to loop through (for trimtemp in trim)
I have one list that I want to take a slice of, reverse that
I have a list that I want to put in a dictionary, for simplicity
I have a unordered list that I want to make fill 2 columns, I
I have a list of methods that I want to call named Method1, Method2,
I have a list of elements that I want to split into individual lists
I have a list of names that I want to match case insensitive, is
Using bash, I have a list of strings that I want to use 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.