Sequential Numbers using LINQ

Tijut2k
Posted by Tijut2k under LINQ category on | Points: 40 | Views : 3486
the LINQ Range Operator to populate an ASP.NET ListBox with a Sequence of Numbers.
Eg.1
lstBox.DataSource=Enumarable.Range(1,20).ToList()
lstBox.DataBind();

the LINQ Range Operator to Write Console with a Sequence of Numbers.
Eg.2
public void RangeOpe () {
var numbers = from n in Enumerable.Range(100, 50)
select new {Number = n, OddEven = n % 2 == 1 ? "odd" : "even"};

foreach (var n in numbers) {
Console.WriteLine("The number {0} is {1}.", n.Number, n.OddEven);
}

Comments or Responses

Posted by: T.saravanan on: 5/5/2011 Level:Silver | Status: [Member] [MVP] | Points: 10
Hi,

Kindly post your code inside the code tag.

Login to post response