Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

contains with ignore case c#

/*
OrdinalIgnoreCase compares the character codes without cultural aspects. 
This is good for exact comparisons, like login names, but not for sorting 
strings with unusual characters like é or ö. This is also faster because there
are no extra rules to apply before comparing.
*/
  
string FirstString = "I love my country!";
string SecondString = "Love";
bool result = FirstString.Contains(SecondString, StringComparison.OrdinalIgnoreCase);
Console.WriteLine(result);

/*
InvariantCultureIgnoreCase uses comparison rules based on english, but without
any regional variations. This is good for a neutral comparison that still takes
into account some linguistic aspects.
*/
string FirstString = "I love my country!";
string SecondString = "Love";
bool result = FirstString.Contains(SecondString, StringComparison.InvariantCultureIgnoreCase);
Console.WriteLine(result);
Comment

c# Case insensitive Contains(string)

// To test if the string paragraph contains the string word
culture.CompareInfo.IndexOf(paragraph, word, CompareOptions.IgnoreCase) >= 0
Comment

PREVIOUS NEXT
Code Example
Csharp :: telerik winforms get value of selected rows from grid 
Csharp :: unity collision.impulse 
Csharp :: c# internalsvisibleto 
Csharp :: c# object is enum 
Csharp :: create blazor server 
Csharp :: how to know pm or am C# 
Csharp :: Show empty message in data table angular material, If no data found 
Csharp :: Send Hotmail, Outlook, Office365 Email using SMTP C# .NET 
Csharp :: how to download somthing from one drive unity 
Csharp :: c# if string in licbox 
Csharp :: rename join table ef core 
Csharp :: wpf keydown detect if control key is down 
Csharp :: C# How to display text in console 
Csharp :: c# how to get a file path from user 
Csharp :: how to iterate a generic list in c# 
Csharp :: 2d array 
Csharp :: concatenate two lists in c# 
Csharp :: c# list get last element 
Csharp :: convert date to days c# 
Csharp :: c# insert backslash in string 
Csharp :: ef core many to many fluent api 
Csharp :: strinng.indexOf c# 
Csharp :: insert data to access database c# 
Csharp :: c# C# read text from a certain line number from string 
Csharp :: using statement c# 
Csharp :: string.format() c# 
Csharp :: flyt wordpress fra localserver 
Csharp :: RestRequest AdvancedResponseWriter site:stackoverflow.com 
Csharp :: unity mathf.clamp 
Csharp :: Calculate relative time in C# 
ADD CONTENT
Topic
Content
Source link
Name
5+5 =