C#中使用IndexOf()判断字符串在字符串数组中第一次出现的索引位置

            string[] s = new string[4] {"111","222","333" ,"444"};
            string s1 = "3335";
            //判断字符串的前几位在另一个字符串数组中第一次出现的索引位置
            index = Array.IndexOf(s, s1.Substring(0, 2));

 

posted on 2019-09-06 16:46  Keepshining  阅读(4339)  评论(0)    收藏  举报

导航