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

  • Home
  • SEARCH
  • 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 6933685
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T11:51:50+00:00 2026-05-27T11:51:50+00:00

How do you do Linq with non-lambda express for the following (which does not

  • 0

How do you do Linq with non-lambda express for the following (which does not work):

string[] words = { "believe", "relief", "receipt", "field" }; 
var wd = (from word in words
          select word).Any(Contains ("believe"));
  • 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-27T11:51:51+00:00Added an answer on May 27, 2026 at 11:51 am

    It’s not clear what good you believe the from wor in words select wor is doing – it’s really not helping you at all.

    It’s also not clear why you don’t want to use a lambda expression. The obvious approach is:

    bool hasBelieve = words.Any(x => x.Contains("believe"));
    

    Note that this isn’t checking whether the list of words has the word “believe” in – it’s checking whether the list of words has any word containing “believe”. So “believer” would be fine. If you just want to check whether the list contains believe you can just use:

    bool hasBelieve = words.Contains("believe");
    

    EDIT: If you really want to do it without a lambda expression, you’ll need to basically fake the work that the lambda expression (or anonymous method) does for you:

    public class ContainsPredicate
    {
        private readonly string target;
    
        public ContainsPredicate(string target)
        {
            this.target = target;
        }
    
        public bool Apply(string input)
        {
            return input.Contains(target);
        }
    }
    

    Then you can use:

    Func<string, bool> predicate = new ContainsPredicate("believe");
    bool hasBelieve = words.Any(predicate);
    

    Obviously you really don’t want to do that though…

    EDIT: Of course you could use:

    var allBelieve = from word in words
                     where word.Contains("believe")
                     select word;
    
    bool hasBelieve = allBelieve.Any();
    

    But that’s pretty ugly too – I’d definitely use the lambda expression.

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

Sidebar

Related Questions

Have the following (non-straightforward) T-SQL query, which i'm trying to convert to LINQ (to
The following link descrip about Non-Relational field types in database: http://wiki.developerforce.com/page/An_Introduction_to_Force_Database one of field
How do I use LINQ across Queryable and non-Queryable data? With the following code
LINQ simplifies database programming no doubt, but does it have a downside? Inline SQL
Linq to SQL creates objects which are IQueryable and full of relations. Html Helpers
I try to write a LINQ statement which returns me all possible combinations of
In a non-Silverlight world, it is easy to use LINQ to create an ObservableCollection.
I have a non-nullable database column which has a default value set. When inserting
I have the following Linq query: (from container in Container join containerType in ContainerType
The output from the following program is: Non-Static Static Non-Static Is this a compiler

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.