【全国软件开发交流群】131627487 【全国软件测试交流群】144758063 【全国计算机技术交流】131628626

在字符串数组中搜索字符串

string[] strArray = {"ABCDEFG", "HIJKLMNOP"};
string findThisString = "JKL";
int strNumber;
int strIndex = 0;
for (strNumber = 0; strNumber < strArray.Length; strNumber++)
{
    strIndex = strArray[strNumber].IndexOf(findThisString);
    if (strIndex >= 0)
        break;
}
System.Console.WriteLine("String number: {0}\nString index: {1}",strNumber, strIndex);
posted @ 2011-04-16 10:37  编程中国  阅读(436)  评论(0)    收藏  举报