static void Main() { //Testing Tasks 1,2,3 Console.WriteLine("---- Testing Tasks 1,2,3 ----"); var point = new Point3D(1, 1, 1); Console.WriteLine($"My point = {point}"); Console.WriteLine($"Zero point = {Point3D.Opoint}"); var distance = DistanceCalculater.CalculateDistance(point, Point3D.Opoint); Console.WriteLine($"Distance between {point} and {Point3D.Opoint} = {distance}"); //Testing Task 4 Console.WriteLine("---- Testing Task 4 ----"); var path = PathStorage.LoadPath(@"..\..\Points.txt"); Console.Write(path); PathStorage.SavePath(path, @"..\..\EditedPoints.txt"); //Testing task 5,6,7 GenericListTest.TestGenericList(); //Testing Task 8,9,10 MatrixTest.TestMatrix(); Type type = typeof(StartUp); object[] allAttributes = type.GetCustomAttributes(false); Console.WriteLine(allAttributes[0].ToString().PadLeft(Console.BufferWidth)); }
/// <summary> /// LD TEST006 - generics /// if for example I have two list, one of "int" and the second of "Book", and I want /// just ADD AN ITEM IN BOTH THE LISTS, I DON'T NEED OF TWO SEPARATED CLASSES /// </summary> private static void Test006() { //here we define the type of list, IT'S THE SAME LIKE WE USUALLY DO HERE: "var bla = new List<int>();" var numbers = new GenericListTest <int>(); numbers.Add(23);// automatically it's suggested to pass an "int" parameter //LD we can use the same approach for a list of books, just by CHANGING the TEMPLATE PARAMETER var books = new GenericListTest <Book>(); books.Add(new Book()); }