devxlogo

Check Whether a String Contains Another String

Check Whether a String Contains Another String

Often, we have to do a string comparison by ignoring the case, or the results end up being wrong. The StringComparison enum provides the “ordinalignorecase” member that allows you to do this. See below for an example.

string searchString = "John"; string completeString = "johnDoe";bool exists = completeString.IndexOf(searchString, StringComparison.OrdinalIgnoreCase) = 0;
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist