Skip to content

Instantly share code, notes, and snippets.

@dnasca
Created March 17, 2015 06:37
Show Gist options
  • Select an option

  • Save dnasca/5af85ffcfe3104ed6214 to your computer and use it in GitHub Desktop.

Select an option

Save dnasca/5af85ffcfe3104ed6214 to your computer and use it in GitHub Desktop.
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