public void Ordered() { LinkList list = new LinkList(); string text = File.ReadAllText(@"C:\Users\Admin\source\repos\Saurabh\DataStructure\LinkedList\inputNumber.txt", Encoding.UTF8); string[] stringSeparator = new string[] { " " }; string[] textArray; textArray = text.Split(stringSeparator, StringSplitOptions.RemoveEmptyEntries); int[] textInteger = new int[textArray.Length]; for (int i = 0; i < textArray.Length; i++) { textInteger[i] = Convert.ToInt32(textArray[i]); } for (int i = 0; i < textInteger.Length; i++) { Console.Write(textInteger[i] + " "); } for (int i = 0; i < textInteger.Length; i++) { list.InsertSorted(textInteger[i]); } list.DisplayIntList(); Console.WriteLine("Enter a string which you want to be found:"); int searchInt = Convert.ToInt32(Console.ReadLine()); if (list.SearchInt(searchInt)) { list.DeleteIntKeyElement(searchInt); } else { list.InsertSorted(searchInt); } list.DisplayIntList(); string intString = list.ReturnNumberString(); File.WriteAllText(@"C:\Users\Admin\source\repos\Saurabh\DataStructure\LinkedList\inputNumber.txt", intString); }
static void Main(string[] args) { LinkList theList = new LinkList(); theList.insertFirst(22, 2.99); theList.insertFirst(44, 4.99); theList.insertFirst(66, 6.99); theList.insertFirst(88, 8.99); theList.displayList(); Link f = theList.find(44); if (f != null) { Console.WriteLine("Found link with key " + f.iData); } else { Console.WriteLine("Can't find link"); } Link d = theList.delete(66); //delete item if (d != null) { Console.WriteLine("Deleted link with key " + d.iData); } else { Console.WriteLine("Can't delete item"); } theList.displayList(); Console.ReadKey(); }