string[] name =new string[1000];
for (int i = 0; i < 1000; i++)
{
name[i] = i.ToString();
}
Stopwatch stopwatch = new Stopwatch();
stopwatch.Start();
IEnumerable<string> storName = from n in name
where (n.Length == (from n1 in name
orderby n1.Length
select n1.Length).First()
)
select n;
foreach (string s in storName)
{
Console.WriteLine(s);
}
stopwatch.Stop();
Console.WriteLine(stopwatch.Elapsed);
Console.ReadLine();
以上代码在控制台运行上面name的长度为1000的时候走红色的部分。。
超过10000时就不走了(断点就是不进去)。。为什么
很郁闷。。
linq
------解决方案--------------------------------------------------------
不会,肯定走,你是不是很慢啊
------解决方案--------------------------------------------------------
IEnumerable<string> storName = name.Where(n => n.Length == name.First().Length);