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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T17:07:33+00:00 2026-06-17T17:07:33+00:00

I am confused if the parameter fruit (which I know is an input parameter)

  • 0

I am confused if the parameter fruit (which I know is an input parameter) is returned if the condition is true for predicate. As the following piece of code signifies:

List<string> fruits = new List<string> {
    "apple",
    "passionfruit",
    "banana",
    "mango",
    "orange",
    "blueberry",
    "grape",
    "strawberry"
};

IEnumerable<string> query = fruits.Where(fruit => fruit.Length < 8);
// query contains: {apple,banana,mango,orange,grape}

IEnumerable<string> query2 = query.Where(fruit => fruits.Contains("apple"));

foreach (string fruity in query2)
{
    Console.WriteLine(fruity);
}

// finally returns: {apple,banana,mango,orange,grape}

Therefore it seems as if input is returned if condition is true.

Kindly guide me if I’m wrong

  • 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-06-17T17:07:34+00:00Added an answer on June 17, 2026 at 5:07 pm

    Where returns a filtered sequence of the input for which the predicate returned true. It is applied to each element in turn, and that item is either yielded or discarded. Basically:

    public static IEnumerable<T>(this IEnumerable<T> source, Func<T,bool> predicate)
    {
        foreach(var el in source) {
            if(predicate(el) {
                yield return el;
            }
        }
    }
    

    Look at the names:

    IEnumerable<string> query2 = query.Where(fruit => fruits.Contains("apple"));
    

    That says, for every fruit, see if the entire set (fruits, note the final s) returns an apple. The list fruits does contain apple, so that is true for every fruit.

    You possibly meant:

    IEnumerable<string> query2 = query.Where(fruit => fruit.Contains("apple"));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am confused in the following: In C++ we can pass a parameter to
For the following code: def isString(x): if type(x)==str: return True return False When I
The following code fails on MSVC11 with the error cannot convert parameter 1 from
I am confused with what value should I provide for the len parameter in
Confused here... I have two dates which I NSLog to console and get: dates
Mildly confused. I have a combobox that is databound to a list of strings.
Pretty confused right now, while i feel i know a bit about vhosts this
When supplying dates to a stored procedure via a parameter I'm a little confused
Below is a code snippet for passing a table as a parameter to a
Since IEnumerable has a covariant parameter in C# 4.0 I am confused how it

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.