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

php - Invalid Cofiguration - yii\base\InvalidConfigException - Yii2 -

How to show in django cms breadcrumbs full path? -

ruby on rails - npm error: tunneling socket could not be established, cause=connect ETIMEDOUT -