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

  • Home
  • SEARCH
  • 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 6794341
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:12:38+00:00 2026-05-26T18:12:38+00:00

I have a Collection of type string that can contain any number of elements.

  • 0

I have a Collection of type string that can contain any number of elements.

Now i need to find out all those elements that are duplicating and find out only the first occurance of duplicating elements and delete rest.

For ex

 public class CollectionCategoryTitle
    {
        public long CollectionTitleId { get; set; }
        public bool CollectionTitleIdSpecified { get; set; }
        public string SortOrder { get; set; }
        public TitlePerformance performanceField { get; set; }      
        public string NewOrder { get; set; }    
    }

    List<CollectionCategoryTitle> reorderTitles = 
        (List<CollectionCategoryTitle>)json_serializer
            .Deserialize<List<CollectionCategoryTitle>>(rTitles);

Now i need to process this collection in such a way tat it removes duplicates but it must keep the 1st occurance.

EDIT:

I have updated the code and i need to compare on “NewOrder ” property

Thanks

  • 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-26T18:12:38+00:00Added an answer on May 26, 2026 at 6:12 pm

    For your specific case:

    var withoutDuplicates = reorderTitles.GroupBy(z => z.NewOrder).Select(z => z.First()).ToList();
    

    For the more general case, Distinct() is generally preferable. For example:

            List<int> a = new List<int>();
            a.Add(4);
            a.Add(1);
            a.Add(2);
            a.Add(2);
            a.Add(4);
    
            a = a.Distinct().ToList();
    

    will return 4, 1, 2. Note that Distinct doesn’t guarantee the order of the returned data (the current implementation does seem to return them based on the order of the original data – but that is undocumented and thus shouldn’t be relied upon).

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

Sidebar

Related Questions

I have a string serialization utility that takes a variable of (almost) any type
Background: I have a generic collection of type DirectoryCollection<T> and have specified that T
I am busy writing my own collection type and need to have a function
I have a collection FileTypes that holds objects of type FileType. That type has
I have a collection of PHP classes that can be instantiated traditionally using constructors.
Lets say I have collection of documents with specified longitude and latitude. type is
We have a collection of entities of type called Unit , collection of entities
I have a collection of objects of the same type, let's call it DataItem
I have the following code to get the object type of a collection: Dim
I have a datastructure with a field of the float-type. A collection of these

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.