Reputation: 13
When I try compiling the code below on VS2015, I get the following error:
'List int' does not contain a definition for 'ForEach'.
Please help, by converting the code below to a normal foreach (var in type) statement.
Enumerable.Range (0, 4).ToList ().ForEach (x =>
dashboard.RowDefinitions.Add (
new RowDefinition { Height = new GridLength (1, GridUnitType.Star)
}
));
Upvotes: 0
Views: 74
Reputation: 24903
for
is more readable and suitable here, because you don't use argument of ForEach
method and have many usefull actions (Range
, ToList
).
for(int x = 0; x < 4; x++)
{
dashboard.RowDefinitions.Add (
new RowDefinition { Height = new GridLength (1, GridUnitType.Star)}
);
}
Upvotes: 5