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

Popular posts from this blog

html - Difficulties with background-image property -

visual studio code - What does the isShellCommand property actually do and how should you use it? -

ios - Segue not passing data between ViewControllers -