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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T17:33:50+00:00 2026-05-25T17:33:50+00:00

After looking on MSDN, it’s still unclear to me how I should form a

  • 0

After looking on MSDN, it’s still unclear to me how I should form a proper predicate to use the Find() method in List using a member variable of T (where T is a class)
For example:

public class Name
{
    public string FirstName;
    public string LastName;
    public String Address;
    public string Designation;
}

String[] input = new string[] { "VinishGeorge", "PonKumar", "MuthuKumar" };
//ConCatenation of FirstName and Lastname

List<Name> lstName = new List<Name>();

Name objName = new Name();
// Find the first of each Name whose FirstName and LastName will be equal to input(String array declard above).

for(int i =0;i<lstName.Count;i++)
{
    objName = lstName .Find(byComparison(x));
    Console.Writeline(objName .Address + objName.Designation);
}

What should my byComparison predicate look like?

  • 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-25T17:33:50+00:00Added an answer on May 25, 2026 at 5:33 pm

    It’s not clear why you’re looping and calling Find. Normally you’d call Find not in a loop – it will loop for you. Anonymous methods are your friends here though:

    Name found = lstName.Find(delegate(Name name) {
                                  return name.FirstName + name.LastName == x;
                              });
    

    If you’re using C# 3 (even targeting .NET 2) you can use a lambda expression instead:

    Name found = lstName.Find(name => name.FirstName + name.LastName == x);
    

    EDIT: To find all names in input you can use:

    List<Name> matches = lstName.FindAll(delegate(Name name) {
                                   string combined = name.FirstName + name.LastName;
                                   return input.Contains(combined);
                               });
    

    Note that this won’t be terribly efficient as it will look through the whole of input for a match on every Name. However, the more efficient alternatives are more complicated – I think it’s important for you to understand how this code works to start with.

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

Sidebar

Related Questions

After looking on MSDN, it's still unclear to me how I should form a
Where can one find a list of default converters for WPF? After looking into
I am extremely new to Direct2D after just looking at the MSDN start guide
I'm using BindingSource.Find() to return to the user's position after refreshing a DataGridView. I
Looking at this example of named pipes using Overlapped I/O from MSDN, I am
After looking around (for not terribly long I have to admit) I wonder if
After looking at RescueTime for windows/mac, it seems that there's a version for linux
After looking a while other google, and the web, I decided to post my
After looking at several questions/answers here, I'm not seeing what I think I need.
I just joined this site after looking very hard for an answer to my

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.