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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T01:06:36+00:00 2026-06-15T01:06:36+00:00

Possible Duplicate: how can I do use Except() between two SelectListItem lists I have

  • 0

Possible Duplicate:
how can I do use Except() between two SelectListItem lists

I have two list of type IEnumerable <SelectListItem> I need to create a new IEnumerable <SelectListItem> with the elements of the first list that do not exist in the second list.
how can i do this?

I tried to do it with a Except() but it did not work

Example code:

IEnumerable<SelectListItem> SelectListItemA = ....;
IEnumerable<SelectListItem> SelectListItemB = ....;
IEnumerable<SelectListItem> Except = SelectListItemA.Except(SelectListItemB);

  • 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-15T01:06:37+00:00Added an answer on June 15, 2026 at 1:06 am

    This should work, take alook at this example:

                double[] numbers1 = { 2.0, 2.1, 2.2, 2.3, 2.4, 2.5 };
                double[] numbers2 = { 2.2 };
    
                IEnumerable<double> onlyInFirstSet = numbers1.Except(numbers2);
    
                foreach (double number in onlyInFirstSet)
                    Console.WriteLine(number);
    
                /*
                 This code produces the following output:
    
                 2
                 2.1
                 2.3
                 2.4
                 2.5
                */
    

    I guess the problem is that the Equality comparer in your case (for SelectedListItem) isnt defined, or better said things which look the same are not simply the same objects, in this case you will have to provide the [IEqualityComparer] to define which elements are actually equal1:

    public static IEnumerable<TSource> Except<TSource>(
        this IEnumerable<TSource> first,
        IEnumerable<TSource> second,
        IEqualityComparer<TSource> comparer
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Can I use predefined namespaces when loading an XDocument? I have following
Possible Duplicate: Can we use any other TAG inside <ul> along with <li>? Or
Possible Duplicate: How can I use a string with the same name of an
Possible Duplicate: Rename Oracle Table or View I know you can use ALTER TABLE
Possible Duplicate: Escape @ character in razor view engine how can i use '@'
Possible Duplicate: Can I scroll a ScrollView programmatically in Android? I have a chat
Possible Duplicate: Can I use ASP.NET MVC together with regular ASP.NET Web forms Let's
Possible Duplicate: Where can I get a list of all countries/cities to populate a
Possible Duplicate: How can I use the Google App engine bulkloader to back up
Possible Duplicate: How can one use multi threading in php applications Does anybody know

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.