Home
Manage Your Code
Snippet: Get the index of the string within another string without match case (C#)
Title: Get the index of the string within another string without match case Language: C#
Description: using CompareInfo.IndexOf() in System.Globalization name space. The old way is first make it all ToTower(), then index. Views: 89
Author: Yan Xing Yang Date Added: 7/31/2008
Copy Code  
1
2using System.Globalization;
3
4string strParent = "The Codeproject site is very informative.";
5
6string strChild = "codeproject";
7// We create a object of CompareInfo class for a neutral culture or a culture insensitive object
8CompareInfo Compare = CultureInfo.InvariantCulture.CompareInfo;
9
10int i = Compare.IndexOf(strParent,strChild,CompareOptions.IgnoreCase);
11