Пример #1
0
        // Ex 3: Use virtual/override
        public void Ex3_Virtual()
        {
            ChildA a = new ChildA("hello");

            a.Method01(); // no override
            a.Method02(); // override
            a.Prop01 = "test";
            Console.WriteLine("Prop01: {0}", a.Prop01);

            ChildA b = new ChildB();

            b.Method03(); // Sealed
            b[0] = "Hello world";
            Console.WriteLine("Indexer: {0}", b[0]);
            b.OnChangeCustom += (o, e) => { Console.WriteLine("Test override"); };
        }
Пример #2
0
 // Ex 2: Use base keyword
 public void Ex2_Base()
 {
     ChildA a = new ChildA("hello");
 }