0
shah123's Avatar
Contributor
I have main method as:

Code:
Console.WriteLine("Please Enter the data to be Inserted in the LinkList...");

link lnk = new link();

String str = "";

while (true)

{

str = Console.ReadLine();

if(str.Equals("e"))

break;

add(str);

}

 Console.WriteLine("The data in nodes are : ");

display();

Console.WriteLine("Do you want to put the data at some specific position?");

String myString = Console.ReadLine();


Console.WriteLine("Enter element to put at specified position :");

String s = Console.ReadLine();

Int32 ind = Int32.Parse(s);

insertAt(str, ind);

When i try to insert the data at some specific position it inserts the element "e" at some random position and also it puts any required element on that position. e.g.

Console: Do you want to put the data at some specific position?

pos: 1

Console.WriteLine("Enter element to put at specified position :");

3

So when it display the list it shows like as :

3

5

6

7

e

1

8

Why it is inserting "e" in the middle?

Please advise. Thanks
0
shabbir's Avatar, Join Date: Jul 2004
Go4Expert Founder
Have separate thread with appropriate title for your separate queries as that helps when some one else is finding something.
0
shah123's Avatar
Contributor
Thanks. I will put in separate thread.