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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T07:20:42+00:00 2026-06-14T07:20:42+00:00

I have an array of strings string[] tmp = foo(); If NONE of the

  • 0

I have an array of strings

string[] tmp = foo();

If NONE of the strings in foo contain either “bar” or “baz” I want to execute some code.
Is this the proper way to query this object?

if(!tmp.Any(p => p.ToLower().Contains("bar") || p.ToLower().Contains("baz"))
 doSomething(); 

The || seems silly. Should I be using a regular expression here or is there an even better way to be doing this? ***Also note the values in tmp are like "bar=someValue" like a query string. This code works ok but I’m certain it can written better. Thanks for any tips of feedback.

  • 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-14T07:20:43+00:00Added an answer on June 14, 2026 at 7:20 am

    Any better? I don’t know but should work.

    if(!tmp.Select(x => x.Split('=')[0])
                        .Intersect(new[] { "foo", "baz" }, 
                                   StringComparer.InvariantCultureIgnoreCase).Any())
        doSomething();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an array of strings plus one additional string. I want to use
I have array of strings, String[] data and it's 10 elements has value P
I have a an array of strings:e.g: string [] names ={P,A,B,G,F,K,R} I have another
I have an array: string myArray={15,56,17-75,78,100-150,130} I want to filter myList by arrayElements .
I have an array of string, that look like this /var/folders/zy/zy4FzDGQEUuq9jZ1hTRFHk+++TI/-Tmp-/tarDir0172809001305545247/0516_GTB_HP_01.pdf /var/folders/zy/zy4FzDGQEUuq9jZ1hTRFHk+++TI/-Tmp-/tarDir0172809001305545247/0516_ETB_HP_28.pdf As you
I have following String Array tmp = [null, null, null, Mars, Saturn, Mars] coming
I have a string array: string[] authors = new string[3]; authors[0] = Charles Dickens;
I have this array: string[,] productData = new string[5,7]; I bind it to a
An array is defined of assumed elements like I have array like String[] strArray
i have an array below string stringArray = new stringArray[12]; stringArray[0] = 0,1; stringArray[1]

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.