Created
February 17, 2014 13:07
-
-
Save s2kw/9050188 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; | |
using System.Text; | |
using System.Linq; | |
using System.Collections.Generic; | |
class Program{ | |
public class A{ | |
protected string member = "class a's member"; | |
public virtual string method_a(){ | |
return "class A method a\t" + this.member; | |
} | |
} | |
public class B:A{ | |
private string member = "class b's member"; | |
public override string method_a () | |
{ | |
return "class B method a\t" + this.member; | |
} | |
} | |
public class C:B{ | |
//string member = "class c's member"; | |
public override string method_a () | |
{ | |
return "class C method a\t" + this.member; | |
} | |
} | |
static void Main (string[] args) { | |
A a = new A (); | |
B b = new B (); | |
C c = new C (); | |
StringBuilder sb = new StringBuilder (); | |
sb.AppendLine (a.method_a()); | |
sb.AppendLine (b.method_a()); | |
sb.AppendLine (c.method_a()); | |
Console.WriteLine (sb.ToString()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment