Using the Generation operator
The Generation operators used for generate sequence. The Generation operators are Range, Repeat and Empty.
Now, we add the Default.aspx page and write the following code:
Now, double click on Display Record button and write the following code:-
Now run the application and click on Display Record button and get output.
Now, we add the Default.aspx page and write the following code:
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
Now, double click on Display Record button and write the following code:-
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Xml.Linq; public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void btnDisplayRecord_Click(object sender, EventArgs e) { lbDetail.Items.Clear(); var query = from q in Enumerable.Range(1, 30) select new { Number = q, oddEven = q % 2 == 1 ? "odd" : "even" }; foreach (var number in query) { lbDetail.Items.Add("The Number=" + number.Number + number.oddEven); } } }
Now run the application and click on Display Record button and get output.