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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T12:15:15+00:00 2026-05-19T12:15:15+00:00

I quite possibly am doing this the wrong way but; I have a list

  • 0

I quite possibly am doing this the wrong way but;

I have a list of objects in LINQ;

MyObj
  string name
  string somethingElse

List<MyObj> myObjects;

Now I’m trying to see if any object in that list has a string value;

So I have;

if (Model.myObjects.Contains("thisobject", new MyObjComparer()))
{
}

In the comparer I have;

public class MyObjComparer: IEqualityComparer<MyObj>
{
    public bool Equals(string containsString, MyObj obj)
    {
        return obj.name == containsString;
    }
}

How can I use a comparer to check against a string value in an objects field?

  • 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-19T12:15:16+00:00Added an answer on May 19, 2026 at 12:15 pm

    An easier method is to do this:

    if (Model.myObjects.Any(o => o.name == "thisobject"))
    {
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This could quite possibly be the dumbest question ever asked. Our client wants us
It's quite possible a question like this has been asked before, but I can't
It is quite possible that I may not have got the point, but I
I have the following code that was written without Tests but is actually quite
In my application I have quite some void-pointers (this is because of historical reasons,
I'm pretty certain I'm missing something really obvious here but this seems quite bizarre.
Using MySQL I need to have a list (possibly long list) of x,y coordinates.
Nikhil Kothari's Script# is quite possibly one of the most amazing concepts I've seen
I'm not quite sure if this is possible, or falls into the category of
This question was asked quite some time ago, and while it covers possible solutions

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.