tailieunhanh - C# in Depth what you need to master c2 and 3 phần 8

Điều này không làm việc cho các thông số, mặc dù: giả sử chúng ta muốn thực hiện một cuộc gọi đến MyMethod, tuyên bố là void MyMethod (string [] tên). Mã này sẽ không làm việc:Thay vào đó, bạn phải nói với trình biên dịch của mảng bạn muốn khởi tạo: | Extension methods in .NET 265 returned. This pattern of returning one enumerable based on another is pervasive in the Enumerable class. NOTE Efficiency buffering vs. streaming The extension methods provided by the framework try very hard to stream or pipe data wherever possible when an iterator is asked for its next element it will often take an element off the iterator it s chained to process that element and then return something appropriate preferably without using any more storage itself. Simple transformations and filters can do this very easily and it s a really powerful way of efficiently processing data where it s possi-ble but some operations such as reversing the order or sorting require all the data to be available so it s all loaded into memory for bulk processing. The difference between this buffered approach and piping is similar to the difference between reading data by loading a whole DataSet versus using a DataReader to process one record at a time. It s important to consider what s required when using LINQ a single method call can have significant performance implications. Let s do something a little more adventurous now we ll use a lambda expression to remove the even numbers. Filterinế with Where and chaininế method calls toếether The Where extension method is a simple but powerful way of filtering collections it accepts a predicate which it applies to each of the elements of the original collection. Again it returns an IEnumerable T and this time any element that matches the predicate is included in the resulting collection. Listing demonstrates this applying the odd even filter to the collection of integers before reversing it. We don t have to use a lambda expression here for instance we could use a delegate we d created earlier or an anonymous method. In this case and in many other real-life situations it s simple to put the filtering logic inline and lambda expressions keep the code concise. Listing Using the Where .

TỪ KHÓA LIÊN QUAN
crossorigin="anonymous">
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.