Skip to main content

Linked List in ASP.NET



Create a Linked link or Generic List in Asp.Net

A Simple way to create a Linked List in ASP.Net C# by using

List&ltT&gt = new List&ltT&gt(); Class.

&ltT&gt Can be any data type or user defined class.

Like, if you want to create a List of Sting or int datatype.

List&ltString&gt LS= new List&ltString&gt();
or
List&ltint&gtLI= new List&ltint&gt();

to add nodes in List:

LS.Add("U");
LS.Add("M");
LS.Add("R");

or

LI.Add(7);
LI.Add(8);
LI.Add(6);


List will be shown like this :

U->M->R
or
7->8->6

If you want to add more than one variables in one Node then you need to create a class for that.

For exp u want to store Name and Age of student in a node. Then you first create a user defined class for that.

class Node
{
public String Name;
public int Age = 0;

public Node()
{ }

public Node(String data, ag)
{
this.Name = data;
this.Age=ag;
}
}


Here we have defined a class name called Node and in this we declared two members named Name and Age. We have defined to constructors, default and overloaded constructor.

now you can use this class to create your custom Linked List.
Like,

List&ltNode&gt LStudents= List&ltNode&gt();

To add new Node:

Node a = new Node();
a.Name="UMR";
a.Age=25;
LStudents.Add(a);

Node a2 = new Node();
a2.Name="UMR2";
a2.Age=26;
LStudents.Add(a2);


you may use constructor:
Node a = new Node("UMR",25);
LStrudents.Add(a);

You can traverse the Linked List like:

for(int i=0;i&ltList.Count;i++)
{
.
.
.
//your code
.
.
TextBox1.Text=List[i].Name;
TextBox2.Text=List[i].Age;
}

Comments

Popular posts from this blog

Font identifier and Unicode converter for Hindi

Font identifier and Unicode converter for Hindi Fonts are used to represent text in document. Fonts are mainly two kind non-Unicode and Unicode fonts. Complex scripts like Hindi and other Asian languages well represented in Unicode fonts. There are some other ways to write these languages for e.g we can use ASCII/ISCII codes to represent different characters of Hindi, but there are large numbers of characters in Hindi script as compared to English. Therefore, we always need multiple ASCII/ISCII encoded characters combination to represent a single character of Hindi Script. One major problem in these ASCII encoding based fonts is that we cannot easily transfer text from one system to another. The system must have these text fonts. There is hundreds of ASCII/ISCII encoding based fonts which are used to write Hindi text. New software systems are based on Unicode fonts.                   ...

Hindi to Punjabi Machine Translation System

The Hindi To Punjabi Machine Translation System has been developed using Direct/Rule based Approach by Dr.Vishal Goyal and Dr. G.S Lehal. Various large size Lexicon resources  have been used to map Source and Target language words.  In general, if the two languages are structurally similar, in particular as regards lexical correspondences, morphology and word order, the case for abstract syntactic analysis seems less convincing. Since the present research work deals with a pair of closely related language, so the direct translation system is the obvious choice. The overall system architecture shown below, is adopted for Hindi to Punjabi Machine Translation System. The system is divided into three stages: Preprocessing, Translation Engine, and Post Processing stage. Following is the description of various steps of this architecture.  PreProcessing   The pre-processing stage is a collection of operations that are applied on input  data to make it pr...

Binary Search Tree in ASP .Net

Binary Search Tree in ASP .Net To create Binary Search Tree(BST) in Asp.net application   first you need to create a Node class. Something like following : class Node {     public String data;     public int freq = 0;     public Node left, right;     public Node()     { }     public Node( String data)     {         this .data = data;         left = null ;         right = null ;     } } Next You need to create a class including different functions.Like class BinaryTreeImp {     Node root;     String outputfreq = "" ;     static int count = 0;     public BinaryTreeImp()     {      ...