- Beginning C# 7 Hands-On:Advanced Language Features
- Tom Owsiak
- 223字
- 2021-07-02 15:29:29
Determining the values in a collection
Now that we have collections of items to go through, we can do that. To do this, enter the following:
IEnumerable<int> valuesMoreThanTen = lst.Where(x => x >10);
Here, we first operate on the list of numerical values, so we say valuesMoreThanTen. To make this happen, you enter the name of the list, which is lst. Notice in the pop-up tip all of the functions that have become available. One of them is Where<>. After you select Where<>, you can specify a condition that applies, in our case, where x is such that x is greater than 10, or (x => x > 10), and close this with a semicolon.
If you hover your mouse over Where, and look where it says IEnumerable<int>, it says that it returns, in other words, an IEnumerable construct, which we can iterate through with a foreach loop, for example. Further, it says (Func<int,bool>... and then there is a predicate delegate. So, we will take each value and we'll basically apply some action to it. We'll check whether some condition holds: either the condition holds on it or it doesn't.
As you can see, we basically have LINQ, and then we have inside that, a Lambda expression. So, to make use of it, you'll enter the following next:
valuesMoreThanTen.ToList().ForEach(x => sampLabel.Text += $"<br>x={x}");
- INSTANT OpenCV Starter
- FreeSWITCH 1.8
- Instant Zepto.js
- R大數據分析實用指南
- Python機器學習基礎教程
- 數據結構習題解析與實驗指導
- Java EE核心技術與應用
- Creating Stunning Dashboards with QlikView
- 從零開始學C#
- Python+Tableau數據可視化之美
- Mastering Web Application Development with AngularJS
- Oracle GoldenGate 12c Implementer's Guide
- 軟件項目管理實用教程
- Learning Python Data Visualization
- 3ds Max 2018從入門到精通