Created
September 19, 2014 14:52
-
-
Save tenfortyeight/10e27ca909503d53dcc8 to your computer and use it in GitHub Desktop.
property overwriting
This file contains 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 abstract class MyBase { | |
protected MyBase(){} | |
protected MyBase(Guid id, string name){ | |
Id = id; | |
Name = name; | |
} | |
public Guid Id {get;private set;} | |
public string Name {get;private set;} | |
} | |
public class MyClass : MyBase { | |
protected MyClass(){} | |
public MyClass(Guid id, string name) : base(id, name){} | |
} | |
public class MyOuterMostClass : MyClass { | |
protected MyOuterMostClass(){} | |
public MyOuterMostClass(Guid id, string name){ | |
Id = id; | |
Name = name; | |
} | |
public new Guid Id {get;private set;} | |
public new string Name {get;private set;} | |
} | |
class Program { | |
static void Main() { | |
Console.WriteLine("Testing testing..."); | |
var myC = new MyClass(Guid.NewGuid(), "nisse1"); | |
Console.WriteLine(myC.Id.ToString() + " " + myC.Name); | |
Console.WriteLine(((MyBase)myC).Id.ToString() + " " + ((MyBase)myC).Name); | |
var myOMC = new MyOuterMostClass(Guid.NewGuid(), "nisse2"); | |
Console.WriteLine(myOMC.Id.ToString() + " " + myOMC.Name); | |
Console.WriteLine(((MyBase)myOMC).Id.ToString() + " " + ((MyBase)myOMC).Name); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment