Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
这两个语句之间有任何性能差异吗?
IEnumerable<T>.ToList().ForEach(x => Console.WriteLine(x));
和
foreach (var obj in IEnumerable<T>) Console.WriteLine(obj)
在第一个示例中,您将
Console.WriteLine
在第二个示例中,您将
第一个比第二个有两个性能惩罚:
List