Esempio n. 1
0
        static void Main(string[] args)
        {
            //var Person = new Person();
            // Person.Name = "Sourav";
            // Person.Intro("Kainth");

            //class and Static Function Demo
            var Per = Person.Parse("Sourav");

            Per.Intro("Kainth");

            //constructors demo
            //Default constructor
            var customer = new Customer();

            Console.WriteLine(customer.id);
            Console.WriteLine(customer.Name);

            //Parameter constructor
            var cus = new Customer(1, "Sourav");

            Console.WriteLine("Parameter constructo {0} {1}", cus.id, cus.Name);

            //constructors overloading
            var cusm = new Customer(5);

            Console.WriteLine("constructors overloading {0}", cusm.id);

            //Orders --- Custructoer
            var order = new Order();

            customer.Orders.Add(order);


            //Object Intitialzers
            //without making mutiple const
            var Oi = new ObjectInitializer
            {
                FirstName = "Sourav",
                LastName  = "Kainth"
            };



            Program.Method();

            //Properties
            var prop = new PropertiesDemo(new DateTime(1982, 1, 2));

            //prop.SetDateTime(new DateTime(1980, 1, 1));
            //Console.WriteLine(prop.GetDateTime());

            Console.WriteLine(prop.Birthdate);
            Console.WriteLine(prop.Age);

            //Indexer Demo
            var cookie = new HttpCoookie();

            cookie["name"] = "Sourav";
            Console.WriteLine(cookie["name"]);

            //Inheritance
            var childClass = new ChildClass();

            childClass.Copy(); //accessing parent class method
            childClass.width  = 200;
            childClass.height = 100;
            childClass.AddHyperLink("www.google.com");

            //compostion demo
            var dbMig   = new DbMigrator(new Logger());
            var install = new Installer(new Logger());

            dbMig.Migrate();
            install.Install();

            //boxing and unboxing
            //value type to object --boxing
            int    number = 10;
            Object obj    = number;
            //object type to value --unboxing
            int numx = (int)obj;

            //method overrding
            var program = new Program();

            program.Add(4, 3);
            var methodOverriding = new MethodOverriding();

            methodOverriding.Add(4, 3);
            Console.ReadLine();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            #region Introduction Classes
            /* Demo Introduction Classes */
            //var person = Person.Parse("John");
            //person.Introduce("Eful");
            #endregion

            #region Constructors
            /* Demo Constructors*/
            //var customer = new Customer();
            //customer.Id = 1;
            //customer.Name = "John";

            //var order = new Order();
            //customer.Orders.Add(order);


            //Console.WriteLine(customer.Id);
            //Console.WriteLine(customer.Name);
            #endregion

            #region Methods
            //int number;
            //var result = int.TryParse("abc", out number);
            //if(result)
            //    Console.WriteLine(number);
            //else
            //    Console.WriteLine("Conversion failed.");
            #endregion

            #region Fields
            //var customer = new Customer(1);
            //customer.Orders.Add(new Order());
            //customer.Orders.Add(new Order());

            //customer.Promote();

            //Console.WriteLine(customer.Orders.Count);
            #endregion

            #region Access Modifiers

            //var person = new Person();
            //person.SetBirthDate(new DateTime(1992, 1, 1));
            //Console.WriteLine(person.GetBirthdate());
            #endregion

            #region Properties
            //var person = new Person(new DateTime(1992, 2, 2));
            //Console.WriteLine(person.Age);
            #endregion

            #region Indexers
            //var cookie = new HttpCookie();
            //cookie["name"] = "Efuull";
            //Console.WriteLine(cookie["name"]);
            #endregion

            #region Inheritance
            //var text = new Text();
            //text.Width = 100;
            //text.Copy();
            #endregion

            #region Composition
            var dbMigrator = new DbMigrator(new Logger());

            var logger    = new Logger();
            var installer = new Installer(logger);

            dbMigrator.Migrate();
            installer.Install();
            #endregion
        }