The conversion operators are used to change the type of input objects.This provide a simple and convenient way for converting sequences to other collection types.In this tutorial ,we will learn about the ToList conversion operators.This is very help when you want to differentiate the different data types (int,char,string ,etc.) according to you(customer). This concepts will help you to do it.If you want to display each data type's data one by one in your application then it is more helpful to you.Please read it very care fully and use it in your application according to your goal.
There are some steps to implement this concepts in .net application as given below.
Step 1:- First open your visual studio -->File -->New --> Select ASP.NET Empty website -->OK -->open solution Explorer --> Add New Web form (home.aspx) --> drag and drop List Box and button controls on the web page from toolbox as shown below:-
Step 2:- Now Write write the following c# codes on button clicks (home.aspx.cs) as given below:-
Step 3:- Now Run the Application (Press F5) --> you will see the following output as shown below:-
There are some steps to implement this concepts in .net application as given below.
Step 1:- First open your visual studio -->File -->New --> Select ASP.NET Empty website -->OK -->open solution Explorer --> Add New Web form (home.aspx) --> drag and drop List Box and button controls on the web page from toolbox as shown below:-
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class home :
System.Web.UI.Page
{
protected void
Page_Load(object sender, EventArgs e)
{
}
object[] list = { "Jitendra",
1,'a', "Dhirendra",
3,'b', 2, "Aarti",
4, "Raj",'d','f', "Jitu",
5,"Anu",8 };
protected void
Button1_Click(object sender, EventArgs e)
{
var n = list.OfType<int>();
ListBox1.Items.Add("The Integer values
are:-");
foreach (var int_num in n)
{
ListBox1.Items.Add(int_num.ToString());
}
}
protected void
Button2_Click(object sender, EventArgs e)
{
var m = list.OfType<char>();
ListBox1.Items.Add("The character
values are:-");
foreach (var char_num
in m)
{
ListBox1.Items.Add(char_num.ToString());
}
}
protected void
Button3_Click(object sender, EventArgs e)
{
var p = list.OfType<string>();
ListBox1.Items.Add("The string values
are:-");
foreach (var str_num in p)
{
ListBox1.Items.Add(str_num);
}
}
protected void
Button4_Click(object sender, EventArgs e)
{
ListBox1.Items.Clear();
}
}
No comments:
Post a Comment