您的位置:首页 > 编程语言 > C#

C# IndexOf忽略大小写

2013-10-12 11:41 176 查看
字符串的 IndexOf 方法是对大小写敏感的.幸运的是,这个Globalization 命名空间下包含CompareInfo类,它包含一个对大小写不敏感的 IndexOf 方法. 例如:

using System.Globalization;



string s1 = "C# is a GREAT programming language.";


string s2 = "Great";




CompareInfo Compare = CultureInfo.InvariantCulture.CompareInfo;


int i = Compare.IndexOf( s1, s2, CompareOptions.IgnoreCase );
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: