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: 173
Author: Allan Zhou Date Added: 8/4/2008
Copy Code  
1using System.Globalization;
2
3string strParent = "The Codeproject site is very informative.";
4
5string strChild = "codeproject";
6// We create a object of CompareInfo class for a neutral culture or a culture insensitive object
7CompareInfo Compare = CultureInfo.InvariantCulture.CompareInfo;
8
9int i = Compare.IndexOf(strParent,strChild,CompareOptions.IgnoreCase);
10