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  方圆几百里Idea  阅读(4309)  评论(0编辑  收藏  举报

导航