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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:43:36+00:00 2026-05-10T19:43:36+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 Car {    public string Make;    public string Model;    public int Year; }  {  // somewhere in my code    List<Car> carList = new List<Car>();    // ... code to add Cars ...     Car myCar = new Car();     // Find the first of each car made between 1980 and 2000    for (int x = 1980; x < 2000; x++)    {        myCar = carList.Find(byYear(x));        Console.Writeline(myCar.Make + myCar.Model);    } } 

What should my ‘byYear’ predicate look like?

(The MSDN example only talks about a List of dinosaurs and only searches for an unchanging value ‘saurus’ — It doesn’t show how to pass a value into the predicate…)

EDIT: I’m using VS2005/.NET2.0, so I don’t think Lambda notation is available to me…

EDIT2: Removed ‘1999’ in the example because I may want to ‘Find’ programatically based on different values. Example changed to range of cars from 1980 to 2000 using for-do loop.

  • 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. 2026-05-10T19:43:36+00:00Added an answer on May 10, 2026 at 7:43 pm

    Ok, in .NET 2.0 you can use delegates, like so:

    static Predicate<Car> ByYear(int year) {     return delegate(Car car)     {         return car.Year == year;     }; }  static void Main(string[] args) {     // yeah, this bit is C# 3.0, but ignore it - it's just setting up the list.     List<Car> list = new List<Car>     {         new Car { Year = 1940 },         new Car { Year = 1965 },         new Car { Year = 1973 },         new Car { Year = 1999 }     };     var car99 = list.Find(ByYear(1999));     var car65 = list.Find(ByYear(1965));      Console.WriteLine(car99.Year);     Console.WriteLine(car65.Year); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 65k
  • Answers 65k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer I found another way you can do it was to… May 11, 2026 at 11:16 am
  • added an answer I would say it Is a connection string problem, see… May 11, 2026 at 11:16 am
  • added an answer Somehow some variable names are matched with the regex for… May 11, 2026 at 11:16 am

Related Questions

After looking on MSDN, it's still unclear to me how I should form a
After looking at another question on SO ( Using NaN in C++ ) I
After looking at other questions related to sharing solutions between VS 2005 and VS
I have a query that is dynamically built after looking up a field list
I am in the process of writing a text editor. After looking at other
I'm looking for a multiline regex that will match occurrences after a blank line.
I am looking to setup a transition between two levels(after one level is complete,
What I am looking for is a way to call a method after another
I'm looking for a linux utility that can alter the payloads of network packets
After reading the Head First Design Patterns book and using a number of other

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.