Filter a Range in CSharp
Description
The following code shows how to filter a Range.
Example
using System;/* w w w . j a va 2 s . co m*/
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
class MainClass
{
static void Main()
{
var collection = Enumerable.Range(0, 10)
.Where(x => x % 2 != 0)
.Reverse();
foreach (var element in collection)
{
Console.WriteLine(element);
}
}
}
The code above generates the following result.