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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:30:19+00:00 2026-05-23T07:30:19+00:00

I know LINQ but my knowledge is pretty much only selects, where, orderby and

  • 0

I know LINQ but my knowledge is pretty much only selects, where, orderby and all of the most common functions. Now I have a need to do something that I think is really difficult and
maybe not even possible to do just with LINQ. What I have is a list of people. That’s east
to query but I need to create a text string from that list. The text string has to give a letter followed by the name of each person.

IList<person> Person

I need to be able to have a LINQ statement that checks through the Person list. I need
to be able to look for names that appear more than once. So far I have the following. It works okay but doesn’t give everything needed:

Person[0] name="Fred" &
Person[1] name="Pete" &
Person[2] name="Tony" the var abc = "a) Fred. b) Pete. c) Tony 

var a = "";
foreach (var person in _persons
            .Select((data, value) => new { Data = data, Value = value })
        {
            a = a + (char)(details.Value + 64) + details.name
        }

What I need is the additional functionality so that:

Person[0] name="John" then var abc = "a) John."

Person[1] name="John" &
Person[3] name="John" then var abc = "b) & d) John."

Person[1] name="John" &
Person[2] name="John" &
Person[3] name="John" then var abc = "b),c) & d) John."

In other words, get the names and put a character before them that shows what position the name is in the list. However if the name appears twice then instead of a)name1. b)name1 I need to get a),b) name.

It’s something I can’t really figure out how to do. I would appreciate any advice or pointers that anyone can give me.

  • 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-23T07:30:19+00:00Added an answer on May 23, 2026 at 7:30 am

    Given:

    var persons=new[] {"Fred", "John", "John", "Pete", "John"};
    

    You can write:

            char id = 'a';
            foreach (var row in persons
                .Select(w => new { id = id++, name = w })
                .GroupBy(w => w.name)
                .Select(w => w
                    .Select(ww => ww.id + ")")
                    .Aggregate((c, n) => c + "&" + n)
                    + " " + w.Key))
            {
                Console.WriteLine(row);
            }
    

    And that gives you:

    a) Fred
    b)&c)&e) John
    d) Pete
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to use linq but failed because i have no xml knowledge. What
Now that LINQ to SQL is a little more mature, I'd like to know
I know that when using LinQ it is possible to have an element that
What is the best way to find something in a list? I know LINQ
I know almost nothing about linq. I'm doing this: var apps = from app
Does anyone know of a definitive list of LINQ to SQL query limitations that
I'm new to LINQ,My knowledge on that library is from Jon Skeet's book C#
I know this is not a technical question, but this is something I believe
I've been working around a problem I have when using LINQ to Entities when
I've been programming for a while and have used LINQ-To-SQL and LINQ-To-Entities before (although

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.