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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T14:20:04+00:00 2026-05-11T14:20:04+00:00

I have a list of objects that I want to filter by an integer

  • 0

I have a list of objects that I want to filter by an integer parameter

List<testObject> objectList = new List<testObject>();  // populate objectList with testObjects  objectList.FindAll(GroupLevel0);  private static bool GroupLevel0(testObject item) { return item._groupLevel == 0; }  private class testObject {      public string _FieldSQL = null;      public int _groupLevel; } 

What I’m looking to do is to make GroupLevel0 take in an integer as a parameter instead of hardcoding to 0. I’m working in .NET 2.0 so lambda expressions are a no-go. Is it even possible to pass a parameter into a predicate?

Thank you,

  • 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-11T14:20:04+00:00Added an answer on May 11, 2026 at 2:20 pm

    If you’re stuck with C# 2.0, use an anonymous method – just a slightly clunkier lambda expression (ignoring expression trees):

    List<testObject> objectList = new List<testObject>(); int desiredGroupLevel = 10;  objectList.FindAll(delegate (testObject item) {     return item._groupLevel == desiredGroupLevel; }); 

    Or you could still use a method call to start with:

    List<testObject> objectList = new List<testObject>(); int desiredGroupLevel = 10;  objectList.FindAll(CheckGroupLevel(desiredGroupLevel));  ...  public Predicate<testItem> CheckGroupLevel(int level) {     return delegate (testItem item)     {         return item._groupLevel == level;     }; } 

    If you’re using Visual Studio 2008 but targeting .NET 2.0, however, you can still use a lambda expression. It’s just a compiler trick which requires no framework support (again, ignoring expression trees).

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

Sidebar

Related Questions

I have a list of Python objects that I want to sort by a
I have a class that contains a list of objects. What's the best way
Today I discovered something that makes me sad: objects of type System.Generic.Collections.List don't have
I have IQueryable list of objects of type T which I want to transform
I have a list of objects and I want to reorder them randomly on
Well i have a list of objects List<UserDC> now i would want to display
I have a list of names that I want to match case insensitive, is
I have a list of objects from a django queryset, e.g. my_list = MyObject.objects.filter(variable=something)
I want to be able to have an actual list of objects returned when
I have a set of objects that I want to conform to an interface,

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.