聽說Linq
聽說Linq
using System.Linq;
...
public static void LinqTest() {
int[] array = { 1, 5, 2, 10, 7 };
// Select squares of all odd numbers in the array sorted in descending order
var results = from x in array
where x % 2 == 1
orderby x descending
select x * x;
foreach (var result in results) {
log(result.ToString());
}
}
//49 25 1
reference
Updated: 2023-04-26 09:26
Created: 2017-03-20 03:33