c# - I am trying to understand another programmer's ForEach statement -
when try compiling code below on vs2015, following error:
'list int' not contain definition 'foreach'.
please help, converting code below normal foreach (var in type) statement.
enumerable.range (0, 4).tolist ().foreach (x => dashboard.rowdefinitions.add ( new rowdefinition { height = new gridlength (1, gridunittype.star) } ));
for
more readable , suitable here, because don't use argument of foreach
method , have many usefull actions (range
, tolist
).
for(int x = 0; x < 4; x++) { dashboard.rowdefinitions.add ( new rowdefinition { height = new gridlength (1, gridunittype.star)} ); }
Comments
Post a Comment