////数组集合 string[] str = new string[] { "a", "b", "c", "d", "e", "f", "g" }; ////要查找的字符串 string Num = "c"; ////使用Linq查询,将索引和值查出来, ////新建一个匿名类,属性包括 aa bool类型,和 Index 索引 var tt = str.Select((num, index) => new { aa = (Num == num), Index = index }); ////将得到的输出结果进行判断,查找 aa为true的索引值 ////最后成功得到它的索引 int number = tt.Where(n => n.aa == true).Last().Index;
标签:aa,Index,string,递归,tt,索引,数组 From: https://www.cnblogs.com/lgx5/p/17661061.html