Skip to content

Instantly share code, notes, and snippets.

@s2kw
Created February 17, 2014 13:07
Show Gist options
  • Save s2kw/9050188 to your computer and use it in GitHub Desktop.
Save s2kw/9050188 to your computer and use it in GitHub Desktop.
継承したメンバーはどう見えるかとか。
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