In .NET 3.5, List <> gets the ForEach method. I notice that this does not exist on IList <> or IEnumerable <> what was here here? Is there any other way to do this? A beautiful and easy way to do this?
I ask because I was in a conversation where the speaker always used more general interfaces. But why should I use IList <> as the return type if I want to be able to deploy and use ForEach? Then I just put it back in List <>.
what was here here?
blog , .
? ?
foreach? .
foreach (var foo in ilist) { // etc... }
ForEach IEnumerable<T>, :
ForEach
IEnumerable<T>
public static void ForEach<T>(this IEnumerable<T> enumeration, Action<T> action) { foreach (T item in enumeration) { action(item); } }
.
(), Rx .Run( IEnumerable ), , List custom ForEach. , .
Why is ForEachnot in IEnumerable<T>? Eric Lippert explains this beautifully on his blog . In principle, LINQ should be functional (no side effects), but ForEachclearly non-functional.
But why is it not in IList<T>? Well ... it should be !
IList<T>
Source: https://habr.com/ru/post/1748247/More articles:Process Control with Python - pythonUiwebview is updated after scaling and compression - refresh- [UIImage drawInRect:]/CGContextDrawImage() не освобождает память? - memory-managementPrevent row duplication with all non-unique columns (only with MySQL)? - databaseusing visual studio 2010 and speech recognition in windows 7? - visual-studio-2010Windows Script package to replace environment variables in a file - windowsXML problem in the main menu example - androidDataGridView: how to do scroll synchronization in current cell? - visual-studio-2005лучше jquery прокрутите до плагина, чем scrollTo? - jqueryЛучшее из обоих миров: клавиши со стрелками для перемещения курсора или перелистывания буферов - vimAll Articles