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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T06:40:55+00:00 2026-05-16T06:40:55+00:00

i have a List<my_Custom_Class> and List<string> . My custom class has various items in

  • 0

i have a List<my_Custom_Class> and List<string>. My custom class has various items in which one is DCN number and list<string> contains only DCN number. So I need to check the List<Custom_Class> contains any dcn from List<string>.

For example suppose List1 = List<Custom_Class> and List2 = List<String>. If List1 has 2000 items and list2 has 40000 items on which 600 items from List1 exists in List2. So in this case i need 1400 as my output List as list1. So what would be the expression.
Also one more case is here since List1 contains various items , other items values might be different but the DCN must be same. That I need to check only the similarity of DCN.

Below is my class. Now from datatable i am adding DCN to a List<String> Dcns;

 public class DocumentInfo
    {

        public string ImageType { get; set; }
        public string FileFullPath { get; set; }
        public string BatchName { get; set; }
        public string FileName { get; set; }
        public string DCN { get; set; }
        public string MemberID { get; set; }
        public string NPI { get; set; }
        public string TaxID { get; set; }
        public string Client { get { return DCN.Substring(0, 2); } }
     }

So here in my case I have 493K DCNS in List<string>Dcns and 110K DCNS in List<DocumentInfo>. I need to filter the duplicates records from 110K DCNs. Or can say substract the two list. I need to remove all duplicate dcns that exists in List. Say If 70K records are duplicate then my resultant list of document info will be of List of rest 40K. Distinct/Except is not working. LINQ/ Lambda Exp will be preferrable.

I need it urgently and ASAP.

Thanks in adv.

  • 1 1 Answer
  • 1 View
  • 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-16T06:40:56+00:00Added an answer on May 16, 2026 at 6:40 am
    var dcnSet = new HashSet<string>(Dcns);
    docInfoList.RemoveAll(el => dcnSet.Contains(el.DCN));
    

    The HashSet isn’t strictly necessary, but it makes the difference between O(m * n) and O(m + n), where is m and n are the number of elements in each list.

    EDIT:

    RemoveAll removes the elements from the existing List in place. It does not create a new List. It returns the number of elements removed, but if you don’t care about that you can just discard the return value.

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

Sidebar

Related Questions

So, I have a list containing a custom class, MyClass MyClass has properties, which
I have a AutoCompleteTextView and a custom AutoCompleteTextView adapter. my list has 20 items
I have custom List which has image field. I have to display the image
I have a List of custom object, which consist of a custom list. class
In my SharePoint List I have a custom field which is a filtered lookup.
I have an AlertDialog in my application. It contains a list of custom views
Currently, I have a custom list adapter that has some logic that hide/show a
Possible Duplicate: Sort a Custom Class List<> I have a Generic Collector List and
Hi i have a tab activity which show a list of items (ListView) .
I have set onItemClicklistener on my custom list view but onItemClicklistener not working I

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.