shah123

Hi All,

I am working on linked list application which the structure is as:
[code]
public static void Main(String[] args)
{
Console.WriteLine("Please Enter the data to be Inserted in the LinkList...");
Object obj = new Object();
node n = new node();
linklistImp llist = new linklistImp();
ArrayList ast = new ArrayList();
obj = Console.ReadLine();
llist.Insert(ast);


}

// to Insert the data
public void Insert(ArrayList ast)
{
// to Check if node is empty
if (head == null)
{
head = new node();

}

[/code]
This is just some basic structure of Linked List. My question is i want to insert the data on runtime from user entry and store. I am not sure completely what to use in main() to store the elements and how Can you please help.
Thanks




Re: Visual C# General Store array in LinkedList

shah123

I changed a code small bit.
[code]
while (str != "-1") // When i do that it also display -1 as well also when counting it count -1 as well. How to prevent that
{
str = Console.ReadLine();
llist.Insert(str);
//int i = Int32.Parse(str);

}

Console.WriteLine("\n");
Console.WriteLine("The total number of nodes in list are :" + llist.Count());
Console.WriteLine("\n");
Console.WriteLine("The data in nodes are : ");
llist.display();

}

// to Insert the data
public void Insert(String data)
{
// to Check if node is empty
if (head == null)
{
head = new node();
head.data = data;

}
else
{
// if node is not null
node temp = new node();
temp.data = data;
temp.next = head;
head = temp;
}
totalnodes++;
}


[/code]






Re: Visual C# General Store array in LinkedList

shah123

Anybody to help...Please in String Question above

[code]

while (str != "-1") // When i do that it also display -1 as well also when counting it count -1 as well. How to prevent that

[/code]






Re: Visual C# General Store array in LinkedList

shah123

It worked

[code]

while (true)

{

str = Console.ReadLine();

//ast.Add(str);

if (str == "-1")

break;

llist.Insert(str);

}

[/code]