Created
April 9, 2015 03:47
-
-
Save s2kw/2018ffcb0d461ab8f5b7 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.Linq; | |
using System.Collections.Generic; | |
namespace PlayGrournd | |
{ | |
class MainClass | |
{ | |
public static void Main(){ | |
var x = new X (); | |
x.SayName (); | |
var xx = new XX (); | |
xx.SayName (); | |
var r = new Reader (); | |
r.ReadName ( x ); | |
r.ReadName (xx); | |
} | |
public class X{ | |
public void SayName(){ | |
Console.WriteLine ( "X say:" + this.GetType().Name ); | |
} | |
} | |
public class XX:X{ | |
} | |
public class Reader{ | |
public void ReadName( X _x ){ | |
_x.SayName(); | |
Console.WriteLine( "read:" + _x.GetType().Name ); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
X say:X
X say:XX
X say:X
read:X
X say:XX
read:XX
Press any key to continue...