using System;namespace ConsoleApplication1 { public class Test { public int Data; public Test Next; } /// <summary> /// Summary description for Class1. /// </summary> class Class1 { /// <summary> /// The main entry point for the application. /// </summary> [STAThread] static void Main(string[] args) { // // TODO: Add code to start application here // Test head=new Test(); Test temp; head.Data=-1; temp=head; for(int i=0;i<3;i++) { temp.Next=new Test(); temp=temp.Next; temp.Data=i; } temp.Next=null; temp=head.Next; for(int i=0;i<3;i++) { Console.WriteLine("{0} Data is {1}",i,temp.Data); temp=temp.Next; } } } }
{
public class Test
{
public int Data;
public Test Next;
}
/// <summary>
/// Summary description for Class1.
/// </summary>
class Class1
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
//
// TODO: Add code to start application here
//
Test head=new Test();
Test temp;
head.Data=-1;
temp=head;
for(int i=0;i<3;i++)
{
temp.Next=new Test();
temp=temp.Next;
temp.Data=i;
}
temp.Next=null;
temp=head.Next;
for(int i=0;i<3;i++)
{
Console.WriteLine("{0} Data is {1}",i,temp.Data);
temp=temp.Next;
}
}
}
}