C# Syntax - Example of a Lambda Expression - ForEach() over Generic List

前端 未结 6 1023
傲寒
傲寒 2020-12-04 12:00

First, I know there are methods off of the generic List<> class already in the framework do iterate over the List<>.

But as an

6条回答
  •  庸人自扰
    2020-12-04 12:56

    The above could also be written with less code as:

    new List(items).ForEach(
        i => Console.WriteLine(i)
    );
    

    This creates a generic list and populates it with the IEnumerable and then calls the list objects ForEach.

提交回复
热议问题