String.Contains Case Sensitive
String.Contains Case Sensitive
Case Sensitive String.Contain
String.Contains vs IndexOf .Net
I encountered an issue with string contains couple of days ago... well, the fact is - it has no
StringComparison for culture and Case Sensitivity.
I found a better way to do this, and I just wanted to share in a short post:
string bookTitle = "The Old Man and the Sea";
if (bookTitle.IndexOf("the old man") > -1)
{
// this is case sensitive
}
if (bookTitle.IndexOf("the old man", StringComparison.OrdinalIgnoreCase) > -1)
{
// this is ignore case
}
There are some more options in the StringComparison , but I'll leave it to you to play with
Good day,
Elad Shalom,
CTO at ITweetLive.com
Case Sensitive String.Contain
String.Contains vs IndexOf .Net
I encountered an issue with string contains couple of days ago... well, the fact is - it has no
StringComparison for culture and Case Sensitivity.
I found a better way to do this, and I just wanted to share in a short post:
string bookTitle = "The Old Man and the Sea";
if (bookTitle.IndexOf("the old man") > -1)
{
// this is case sensitive
}
if (bookTitle.IndexOf("the old man", StringComparison.OrdinalIgnoreCase) > -1)
{
// this is ignore case
}
There are some more options in the StringComparison , but I'll leave it to you to play with
Good day,
Elad Shalom,
CTO at ITweetLive.com
Hi, Neat post. There's an issue with your site in internet explorer, may
ReplyDeletecheck this? IE still is the marketplace leader and a big
part of other people will leave out your magnificent writing due to this problem.
Stop by my site: home inspection brooklyn
pandora
ReplyDeletepolo outlet
ugg outlet
michael kors outlet
red bottoms
oakley sunglasses outlet
nmd adidas
pandora jewelry
michael kors outlet
fit flops
20161021caiyan