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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T12:59:10+00:00 2026-06-13T12:59:10+00:00

char[] delimiter = new char[] {‘ ‘}; string[] names = name.Trim().Split(delimiter, StringSplitOptions.RemoveEmptyEntries); employees =

  • 0
char[] delimiter = new char[] {' '};

string[] names = name.Trim().Split(delimiter, StringSplitOptions.RemoveEmptyEntries);

employees = (List<CMSUser>)employees.Where(
                    e => 
                       (e.FirstName.Contains(names[0]) && e.LastName.Contains(names[1])) ||
                       (e.LastName.Contains(name[0]) && e.FirstName.Contains(name[1]))
                     )

Above, I am trying to use Linq lambda to query employees List. I need to split the search term entered in input box for space character and use it to pull from employees list matching (FirstName && LastName) OR (LastName && FirstName) containing those two search words separated by space.

I don’t know what I am doing wrong in query condition. It is returning all employees in list rather than giving those matching condition.

  • 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-13T12:59:11+00:00Added an answer on June 13, 2026 at 12:59 pm

    I think the problem happens in your second OR clause:

    (e.LastName.Contains(name[0]) && e.FirstName.Contains(name[1])
    

    It should be names not name, otherwise it gets the first and second characters respectively of the name variable.

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

Sidebar

Related Questions

I have two extension methods: public static string ToString(this List<object> list, char delimiter) {
I have a program where an array gets its data using string.Split(char[] delimiter). (using
I've used the following split function: CREATE FUNCTION dbo.Splitfn(@String varchar(8000), @Delimiter char(1)) returns @temptable
Ok, so I have the code char *token; char *delimiter = ; token =
char c='c'; int i=10; double d =50; long l=30; String s=Goodbye; Are these statement
String SomeLongString = JavaAPIMethodFor (String[] strings, String delimiter); Or this could work as well:
I try to split a String into tokens. The token delimiters are not single
I'm having a hard time deduping a list based on a specific delimiter. For
I'm new to C and trying to split a character array (which I receive
Consider the following class definition: class StrToTokens { StrToTokens(const char* str, const char* delimiters

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.