private static void DemonstrateExtensionMetod() { var list = new RecursiveLinkedList <int>(); list = list.AddElementToPresortedList(1) .AddElementToPresortedList(7) .AddElementToPresortedList(3) .AddElementToPresortedList(5); var newList = list.AddElementToPresortedList(0); ShowList(list, "list without zero"); ShowList(newList, "list with zero"); }
private static void DemonstrateExceptions() { Console.WriteLine("--Consider the similarity between the two implimentations behaviour:"); Console.WriteLine("-LINQ Sort:"); try { var libList = new List <ExampleClass> { new ExampleClass { Foo = 6 }, new ExampleClass { Foo = 4 } }; libList.Sort(); } catch (Exception ex) { Console.WriteLine(ex.InnerException.Message); } Console.WriteLine("-Custom sort inside AddElementToPresortedList():"); try { var customList = new RecursiveLinkedList <ExampleClass>(); customList.AddElementToPresortedList(new ExampleClass { Foo = 4 }) .AddElementToPresortedList(new ExampleClass { Foo = 5 }); } catch (Exception ex) { Console.WriteLine(ex.Message); } }