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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T13:17:25+00:00 2026-05-27T13:17:25+00:00

So I am implementing a project from a book and I am somewhat confused

  • 0

So I am implementing a project from a book and I am somewhat confused as to WHY i need these lambdas.

public class Cart
{
    private List<CartLine> lineCollection = new List<CartLine>();
    public class CartLine
    {
        public Product Product { get; set; }
        public int Quantity { get; set; }
    }
    public void RemoveLine(Product product)  
    {
        lineCollection
          .RemoveAll(p => p.Product.ProductID == product.ProductID);
    }
}

Why do I need .RemoveAll(p=> p.Product.ProductID == product.ProductID)?
Does it just have to do with .RemoveAll NEEDING a lambda expression? I’m not sure why I can’t use this.Product.ProductID, I realize Product is a list, is p=> P.Product doing some sort of iteration and comparing the values till it finds what it needs?

Product is defined in

public class Product
{
    public int ProductID { get; set; }
    public string Name { get; set; }
    public string Description { get; set; }
    public decimal Price { get; set; }
    public string Category { get; set; }
}

I’m generally confused as to the purpose of Lambdas in these kinds of things. Is there some equivelant to p=>p.Product.ProductID == product.ProductID
I could see not using Lambdas so I could understand more what it is shorthand for??

I can’t seem to wrap my head around this one, and thanks in advance.

  • 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-27T13:17:25+00:00Added an answer on May 27, 2026 at 1:17 pm

    RemoveAll implementation has some sort of iterator which calls your anonymous function for each iteration. Like:

    iterator {
        your_lambda_function(current_item);
    }
    

    And p => p.Product.ProductID == product.ProductID can be rewritten as:

    delegate(CartLine p) { return p.Product.ProductID == product.ProductID; }
    

    which could look a bit clearer for you

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

Sidebar

Related Questions

I am implementing a project in which I am getting the product list from
I'm implementing the TTThumbsViewController from the Three20 project and things are finally starting to
I'm implementing a interpreter-like project for which I need a strange little scheduling queue.
I'm implementing the recaptcha control from google. I built a simple c# test project
I'm implementing a somewhat complex configuration section for a system monitoring project: <monitoring> <components>
While implementing the code from this question on my project I realized there's 3
Is there any way to instantiate a class based it name from different project/.dll
I need to produce different WARs from a Maven project, according to values that
I am implementing some networking stuff in our project. It has been decided that
I am implementing a small database(university Project) and i am facing the following problem.

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.