private static void Main(string[] args) { // We have same methods same method definition in parent classes and child classes. Since we have created // the object of child class so methods of child class will be called and not the methods of the parent class. var T3 = new ThirdClass(); var T3Sum = T3.Add(1, 2); var T3Sub = T3.Sub(2, 1); var T3Mul = T3.Mul(1, 2); FirstClass T1 = new ThirdClass(); // Even though we have instantiated a ThirdClass to object of First class by variable T1 //we can only access the methods of First class, Inorder to access the methods of ThirdClass // we should declare as vertual in parent class(FirstClass) and override in ThirdClass(Dynamic Polymorphism) // we should declare as vertual in parent class(FirstClass) and override in ThirdClass(Dynamic Polymorphism) Console.WriteLine(T1); var T31Sum = T1.Add(1, 2); var T31Sub = T1.Sub(2, 1); var T31Mul = T1.Mul(1, 2); var T31Add = T1.AddExtraInFirstClass(1, 2); var F1 = new MultiplicationClassFirst(); F1.firstClassPublicObject = 10; }
public static void Main(string[] args) { int FirstProgramInt; // we can not create object for abstract classes. var F1 = new MultiplicationClassFirst(); F1.firstClassPublicObject = 12; var F1Sum = F1.Add(1, 2); var F1Mul = F1.Mul(1, 2); var F1Sub = F1.Sub(1, 2); var F2 = new MultiplicationClassSecond(); F2.firstClassPublicObject = 15; var F2Sum = F2.Add(1, 2); var F2Mul = F2.Mul(1, 2); var F2Sub = F2.Sub(1, 2); var F3 = new MultiplicationClassThird(); F3.firstClassPublicObject = 15; var F3Sum = F3.Add(1, 2); var F3Mul = F3.Mul(1, 2); var F3Sub = F3.Sub(1, 2); }
public void ExampleMethod() { // Since this is a class with different name space so in order to create a object to a class which is present // in other name space we need to import that name space as above using AbstractClassesAndOtherPracticeProjectsHere; // If you are working with the same name space then this is not required. var F1 = new MultiplicationClassFirst(); F1.firstClassPublicObject = 15; // Protected internal of another name space is not accesible here,F1.firstClassProtectedInternalObject = 16; }