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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:59:43+00:00 2026-05-13T10:59:43+00:00

I have a collection of TwitterCollection objects held within a List. I am populating

  • 0

I have a collection of TwitterCollection objects held within a List. I am populating the TwitterCollection object (tc) via a foreach loop, and then accessing it through LINQ.

My class with its properties looks like this:

//simple field definition class
public class TwitterCollection
{
    public string origURL { get; set; }
    public string txtDesc { get; set; }
    public string imgURL { get; set; }
    public string userName { get; set; }
    public string createdAt { get; set; }
    public string realURL { get; set; }
    public string googleTitle { get; set; }
    public string googleDesc { get; set; }
}

I then go on to populate it with a loop through a bunch of RegEx matches in a group:

var list = new List<TwitterCollection>();

    foreach (Match match in matches)
    {

        GroupCollection groups = match.Groups;
        var tc = new TwitterCollection
        {
            origURL = groups[1].Value.ToString(),
            txtDesc = res.text,
            imgURL = res.profile_image_url,
            userName = res.from_user_id,
            createdAt = res.created_at,
        };
        list.Add(tc);
    }

Finally I am looking at the collection with LINQ and extracting only certain items for display:

    var counts = from URL in list
                 group URL by URL into g
                 orderby g.Count()
                 select new { myLink = g.Key, Count = g.Count() };

The outcome of all this is a long list of the word “TwitterCollection” in count.myLink and no count of URLs…

I used to have this all working before I shifted to a generic List. Now I have moved for convenience, it won’t work.

I’d seriously appreciate someone taking me out of my misery here! Thanks in advance.

  • 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-13T10:59:43+00:00Added an answer on May 13, 2026 at 10:59 am

    Your list is of type List<TwitterCollection>, so the URL variable is of type TwitterCollection. So a TwitterCollection is what gets selected into g.Key (and hence myLink), and that gets rendered as the string “TwitterCollection”.

    Change your query to:

    var counts = from tc in list
                 group tc by tc.origURL into g  // note by tc.origURL to extract the origURL property
                 ...
    

    (It’s not clear from your code which URL you want to group on, as a TwitterCollection contains several URLs. I’ve used origURL as an example.)

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

Sidebar

Related Questions

I have an collection of iQueryable objects. Looking through intellisense i see 'GetElementAt(int)' but
I have a collection of objects (List) that is bound to a datagridview. How
I have Collection List<Car> . How to compare each item from this collection with
I have a collection of objects to which I'd like to just add a
I have collection of custom objects(assets) which I want to group with LINQ. Custom
I have List collection with around 35,000 strings Typical string looks like this: <i>füüs</i>ampri
I have a collection of string paths like [x1/x2/x3,x1/x2/x4,x1/x5] in a list. I need
I have collection of Questions as List. For each question I want to show
I have a collection List<CustomClass> which I am trying to find a way to
I have collection of objects. I need to sort it by difficult condition, using

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.