score:2
Accepted answer
Trim()
only trims white spaces at the start and end (leading and trailing) of the string... See docs
To remove white spaces within a string you can use:
*str*.Replace(" ", "");
Regex.Replace(*str*, @"\s", "")
where str is the string.
Also consider using a comparison method such as *str*.Equals(*str2*, StringComparison.OrdinalIgnoreCase)
instead of relying on ToUpper()
. Read How to compare strings in C#, it explains string comparison in detail.
Source: stackoverflow.com
Related Query
- linq case insensitive and trimmed comparison
- Linq performing case insensitive comparison
- How can I do case insensitive string search with Linq and SQL Server?
- Check String contain all elements in list using Linq and case insensitive
- linq Expression.Coalesce and case insensitive in the same query
- What ways exist with linq to compare if a case insensitive and culture using string exists within another
- LINQ Contains Case Insensitive
- linq case insensitive (without toUpper or toLower)
- LINQ Where Ignore Accentuation and Case
- How to write EF in linq to include comparison by lower case
- can linq expression be case insensitive
- LINQ to DataSet case insensitive group by
- Case insensitive Contains with Dynamic Linq
- Entity Framework LINQ contains not case insensitive
- Enumerable.Empty<T>().AsQueryable(); This method supports the LINQ to Entities infrastructure and is not intended to be used directly from your code
- Entity Framework and Case Insensitive String Search
- Case insensitive string compare with linq-to-sql and linq-to-objects
- Linq case insensitive join
- Case insensitive string compare in LINQ expression
- how to build case insensitive strong typed LINQ query in c#?
- LINQ string contains another string case insensitive
- LINQ Source Code Available
- Refactor Linq code and "LINQ to Entities does not recognize the method"
- LINQ Query with both CASE statement and SUM function
- MongoDB c# driver: Case Insensitive Compare using in or contains on a list using linq
- How can I code an outer join using LINQ and EF6?
- Relax C# LINQ String Comparison (Trim, Case Insensitive, ??)
- == by default is case insensitive in c# linq
- C# - Linq optimize code with List and Where clause
- IEqualityComparer and Linq Distinct - Hard Code GetHashCode()
More Query from same tag
- What return value to use to match two different kinds of Types
- LinQ Aggregate Error - Sequence contains no elements
- How to convert linq entitySet AND CHILDREN to lists?
- Linq query - Tidy Up/Optimization
- Is there a way to make this in linq?
- Linq to SQL Left Join, Order and Group By Count
- DateTime Comparison in LINQ
- How to get certain SQL query results at the top of the list
- how to select properties in the order from Object using LINQ?
- Optimizing A List of athlete's competitions with LINQ query or similar approach
- Extension to choose which extension to use in Linq
- MissingMemberException when using CallByName
- Favour Verbose Linq expressions?
- LINQ to SQL error message: 'Where' not found
- Convert a string[] to its associated array of enums
- LINQ get max of Amount but return name
- Identify number of conditions in a dynamic LINQ expression
- What construction can I use instead of Contains?
- What's the hardest or most misunderstood aspect of LINQ?
- Access multiple database using linq in asp.net
- Get object from a sub list c#
- Complex grouping in Linq? C#.net
- Enforce ordering of OData items even when $top is used
- Grouping with linq; But with conditions
- id entering as 0 in database in MS SQL Server
- How to retrieve recurring costs using Linq
- Programmatically create a predicate for ordering an IQueryable
- Join and Group in LINQ
- c# Linq filter out records from a list within a dictionary
- extract model from object array using linq