I have a list with several string
, there is a difference between scrolling the list values:
This way:
ListaString.ForEach(delegate(string str)
{
Console.WriteLine(str);
});
Or this:
foreach(string str in ListaString)
{
Console.WriteLine(str);
}
One is more performative than the other? Is there any significant gain?
When is it recommended to use list.foreach
? and foreach
? being List<T>
.
NOTE: I know that Foreach
can be used to traverse arrays
and other things.
But I want to know specifically those two ways above in situations involving List<T>
.