Created
March 17, 2015 06:37
-
-
Save dnasca/5af85ffcfe3104ed6214 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using System; | |
| public class ParentClass | |
| { | |
| public ParentClass() //parameterless constructor, this will be overloaded if the ParentClass constructor is called with a string argument | |
| { | |
| Console.WriteLine("ParentClass Constructor called"); | |
| } | |
| public ParentClass(string Message) //method overloads parameterless ParentClass constructor if ParentClass constructor is called with a string argument | |
| { | |
| Console.WriteLine(Message); | |
| } | |
| public class ChildClass : ParentClass | |
| { | |
| public ChildClass() : base("Derived class controlling the Parent Class") //this will overload the ParentClass default constructor | |
| { | |
| Console.WriteLine("ChildClass Constructor called"); | |
| } | |
| } | |
| } | |
| public class Program | |
| { | |
| public static void Main() | |
| { | |
| var CC = new ParentClass.ChildClass(); | |
| Console.ReadKey(); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment