Пример #1
0
        public void ChildClassExplicitParentClassNewMethod()
        {
            NewAndOverrideClasses.ParentClass childClass = new NewAndOverrideClasses.ChildClassNew();

            System.Diagnostics.Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);
            System.Diagnostics.Debug.WriteLine(childClass.SayHelloWorld());
        }
        public void ChildClassWithNewMethodCallingHelperMethod()
        {
            var childClass = new NewAndOverrideClasses.ChildClassNew();

            System.Diagnostics.Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);
            System.Diagnostics.Debug.WriteLine(childClass.CallMethodToSayHelloWorld());
        }
Пример #3
0
        public void ChildClassWithNewMethodCallingHelperMethod()
        {
            var childClass = new NewAndOverrideClasses.ChildClassNew();

            System.Diagnostics.Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);
            System.Diagnostics.Debug.WriteLine(childClass.CallMethodToSayHelloWorld());
        }
        public void ChildClassExplicitParentClassNewMethod()
        {
            NewAndOverrideClasses.ParentClass childClass = new NewAndOverrideClasses.ChildClassNew();

            System.Diagnostics.Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);
            System.Diagnostics.Debug.WriteLine(childClass.SayHelloWorld());
        }
Пример #5
0
        public void UsingDynamic()
        {
            NewAndOverrideClasses.ParentClass parentType = new NewAndOverrideClasses.ChildClassNew();
            dynamic childType = parentType;

            System.Diagnostics.Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);
            System.Diagnostics.Debug.WriteLine(childType.SayHelloWorld() as string);
        }
Пример #6
0
        public void DeclareAndUseImplicitTypeDeclaration()
        {
            NewAndOverrideClasses.ParentClass parentType = new NewAndOverrideClasses.ChildClassNew();
            var childType = parentType;

            System.Diagnostics.Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);
            System.Diagnostics.Debug.WriteLine("");

            System.Diagnostics.Debug.WriteLine("Parent variable");
            System.Diagnostics.Debug.WriteLine(parentType.SayHelloWorld());
            System.Diagnostics.Debug.WriteLine("");

            System.Diagnostics.Debug.WriteLine("Child variable");
            System.Diagnostics.Debug.WriteLine(childType.SayHelloWorld());
        }
Пример #7
0
        public void DeclareAndChangeVariableType()
        {
            NewAndOverrideClasses.ChildClassNew childClass    = new NewAndOverrideClasses.ChildClassNew();
            NewAndOverrideClasses.ParentClass   newChildClass = childClass;

            System.Diagnostics.Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);
            System.Diagnostics.Debug.WriteLine("");

            System.Diagnostics.Debug.WriteLine("Child variable");
            System.Diagnostics.Debug.WriteLine(childClass.SayHelloWorld());
            System.Diagnostics.Debug.WriteLine("");

            System.Diagnostics.Debug.WriteLine("Parent variable");
            System.Diagnostics.Debug.WriteLine(newChildClass.SayHelloWorld());
        }
        public void DeclareAndChangeVariableType()
        {
            NewAndOverrideClasses.ChildClassNew childClass = new NewAndOverrideClasses.ChildClassNew();
            NewAndOverrideClasses.ParentClass newChildClass = childClass;

            System.Diagnostics.Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);
            System.Diagnostics.Debug.WriteLine("");

            System.Diagnostics.Debug.WriteLine("Child variable");
            System.Diagnostics.Debug.WriteLine(childClass.SayHelloWorld());
            System.Diagnostics.Debug.WriteLine("");

            System.Diagnostics.Debug.WriteLine("Parent variable");
            System.Diagnostics.Debug.WriteLine(newChildClass.SayHelloWorld());
        }
        public void UsingDynamic()
        {
            NewAndOverrideClasses.ParentClass parentType = new NewAndOverrideClasses.ChildClassNew();
            dynamic childType = parentType;

            System.Diagnostics.Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);
            System.Diagnostics.Debug.WriteLine(childType.SayHelloWorld() as string);
        }
        public void DeclareAndUseImplicitTypeDeclaration()
        {
            NewAndOverrideClasses.ParentClass parentType = new NewAndOverrideClasses.ChildClassNew();
            var childType = parentType;

            System.Diagnostics.Debug.WriteLine(System.Reflection.MethodBase.GetCurrentMethod().Name);
            System.Diagnostics.Debug.WriteLine("");

            System.Diagnostics.Debug.WriteLine("Parent variable");
            System.Diagnostics.Debug.WriteLine(parentType.SayHelloWorld());
            System.Diagnostics.Debug.WriteLine("");

            System.Diagnostics.Debug.WriteLine("Child variable");
            System.Diagnostics.Debug.WriteLine(childType.SayHelloWorld());
        }