Beginning C# 7 Hands-On:Advanced Language Features
上QQ阅读APP看书,第一时间看更新

Performing an action on all of the values

Now, one thing that you can do is to perform an action on all the values. So, the way to do that is to enter the following:

vals.ForEach(ShowSquare);

This is how you can call ShowSquare on each value. Notice that, in this case, ShowSquare is named. ShowSquare represents this expression, sampLabel.Text += "<br>" + (x * x); so it's a named quantity.