Created
July 1, 2016 06:20
-
-
Save eternnoir/229992cb6c41751ba9104ec6fda58a3c to your computer and use it in GitHub Desktop.
Call virtual method in contractor.
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
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
BaseClass bc = new ChlidClass(); | |
Console.ReadLine(); | |
} | |
} | |
public class BaseClass | |
{ | |
public BaseClass() | |
{ | |
this.Do(); | |
} | |
protected virtual void Do() | |
{ | |
} | |
} | |
public class ChlidClass : BaseClass | |
{ | |
private string message = null; | |
public ChlidClass() | |
{ | |
message = "Hi"; | |
} | |
protected override void Do() | |
{ | |
if (message.Contains("Hi")) | |
{ | |
Console.WriteLine(message); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment