Via:
var Foo = new[]{ new {Something = 321}};
Why can I do (compile):
Console.WriteLine( Foo[0].Something );
but not:
Foo.ForEach(x => Console.WriteLine(x.Something));
Because Array only has a static ForEach method:
Array
var Foo = new[] { new { Something = 321 } }; Array.ForEach(Foo, x => Console.WriteLine(x.Something));
compiles and works.
to try
Foo.ToList().ForEach(x => Console.WriteLine(x.Something));
since the ForEach extension is only available for lists
EDIT : tested and working.
EDIT2 : Some Workarounds for Creating an Anonymous List
This is SO postThis blog postAnother blog post
Source: https://habr.com/ru/post/910894/More articles:What is this Fusion magazine? - .netHow to request a purchase of several items on the billing function on Google Play - androidRunning JavaScript in href links with Python - javascriptReflect COM Interop Objects - c #HTTPURLConnection - POST multipart / form-data with large file with FixedLengthStreamingMode - androidIs there an alternative to nested fragments? - androidInner fragment Viewpage - androidWeblogic and Oracle: Stuck ExecuteThread - javaHow to find lines containing more than one space between lines in unix? - unixGit connection timeout trying to clone through a proxy server - gitAll Articles