Skip to content

Instantly share code, notes, and snippets.

@luuhq
Created April 5, 2016 23:38
Show Gist options
  • Save luuhq/6323d0b9d70e25db2e40487850e0c227 to your computer and use it in GitHub Desktop.
Save luuhq/6323d0b9d70e25db2e40487850e0c227 to your computer and use it in GitHub Desktop.
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Child1: {0}", new Child1().Caller);
Console.WriteLine("Child2: {0}", new Child2().Caller);
Console.WriteLine("Child3: {0}", new Child3().Caller);
}
public abstract class Parent
{
public Parent([CallerMemberName] string caller = "Default")
{
Caller = caller;
}
public string Caller { get; private set; }
}
public class Child1 : Parent
{
}
public class Child2 : Parent
{
public Child2()
{
}
}
public class Child3 : Parent
{
public Child3()
: base()
{
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment