Esempio n. 1
0
File: Program.cs Progetto: kffl/TSD
        static void Main(string[] args)
        {
            CarSalesBook carSalesBook = new CarSalesBook();

            Func <int, Boolean> isLeapYear = year => (((year % 4 == 0) && (year % 100 != 0)) || (year % 400 == 0));

            Console.WriteLine("2014 is a leap year: {0:B}", isLeapYear(2014));
            Console.WriteLine("2016 is a leap year: {0:B}", isLeapYear(2016));

            var testCollection = new MyCollection <String>();

            Console.WriteLine("Collection is empty: {0:B}", testCollection.isEmpty());
            testCollection.Add("test");
            testCollection.Add("test2");
            testCollection.Add("test3");
            Console.WriteLine("Get 3rd element: {0:S}", testCollection.Get(2));
            Console.WriteLine("Get 3rd element: {0:S}", testCollection.Get(2));
            Console.WriteLine("Collection is empty: {0:B}", testCollection.isEmpty());

            Process[] allProcesses = Process.GetProcesses();
            allProcesses.PrintProcessesInfo();

            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            Console.WriteLine("Hello world!");

            var instance = new MyCollection();
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            NewEra newEra = new NewEra();



            newEra.passCentures();

            HomoSapiens h1 = new HomoSapiens(30, 242, "eg", 55, Race.Negroid);
            HomoSapiens h2 = new HomoSapiens(312, 242, "eg", 60, Race.Mongoloid);
            HomoSapiens h3 = new HomoSapiens(50, 242, "eg", 60, Race.Caucasion);
            HomoSapiens h4 = new HomoSapiens(50, 242, "eg", 60, Race.Negroid | Race.Mongoloid | Race.Caucasion);

            Console.WriteLine((Race.Negroid | Race.Caucasion | Race.Mongoloid).ToString() == Race.Multiracial.ToString());
            HomoSapiens.showDevelopedPeople();

            Console.WriteLine("Intelect: " + h1.getIntelect());
            Console.WriteLine("My Collection");
            MyCollection people = new MyCollection();

            people.add(h1);
            people.add(h2);
            people.add(h3);
            people.sortByAge();
            people.show();


            try
            {
                for (int i = 0; i < 4; i++)
                {
                    Australopithecus.multiply();
                }
            }
            catch (MyException e)
            {
                Console.WriteLine(e.Args.Message);
            }

            Console.WriteLine("");
            Console.WriteLine("Xml serialization");
            Console.WriteLine("");

            MyXmlSerializer serializer = new MyXmlSerializer();

            serializer.xmlSerialize();
            serializer.xmlDeserialize();

            Console.WriteLine("");
            Console.WriteLine("Binary serialization");
            Console.WriteLine("");

            MyBinarySerializer binSerializer = new MyBinarySerializer();

            binSerializer.binarySerialize();
            binSerializer.binaryDeserialize();

            Console.WriteLine("GC start");
            Console.WriteLine("before garbage collection: " + GC.GetTotalMemory(false));
            GC.Collect();
            Console.WriteLine("after garbage collection: " + GC.GetTotalMemory(true));
            HomoSapiens   human1 = new HomoSapiens(30, 242, "eg", 55, Race.Negroid);
            HomoSapiens   human2 = new HomoSapiens(312, 242, "eg", 60, Race.Mongoloid);
            HomoSapiens   human3 = new HomoSapiens(50, 242, "eg", 60, Race.Caucasion);
            WeakReference wr     = new WeakReference(new HomoSapiens(50, 242, "eg", 60, Race.Caucasion));

            human1 = null;
            human2 = null;

            Console.WriteLine("before garbage collection: " + GC.GetTotalMemory(false));
            GC.Collect();
            Console.WriteLine("after garbage collection: " + GC.GetTotalMemory(true));

            Console.WriteLine("before garbage collection: " + GC.GetTotalMemory(false));
            Meat meat = new Meat("meat", 5);

            meat.Dispose();
            Console.WriteLine("after garbage collection: " + GC.GetTotalMemory(true));

            Console.WriteLine("GC end");

            Console.ReadKey();
        }
Esempio n. 4
0
 public myCollectionEnumerator(MyCollection humans)
 {
     this.humans = humans;
 }