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


  1. I know this if off topic but I'm looking into starting my own weblog and was wondering what all is needed to get set
    up? I'm assuming having a blog like yours would cost a pretty penny?
    I'm not very internet savvy so I'm not 100% certain. Any recommendations or advice would be greatly appreciated.
    Appreciate it

    Here is my web page :: Photo booth company around Los Angeles

  2. Hi, Neat post. There's an issue with your site in internet explorer, may
    check 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


Post a Comment

Popular posts from this blog

Advantages and Disadvantages of Decriminalising Privacy

Linked Files in Visual Studio 2010

The Path is Already Mapped in Workspace