Warisan
class Print2D
{
public int X { get; set; }
public int Y { get; set; }
public Print2D(int y,int x)
{
X = x;
Y = y;
Console.WriteLine("2D");
}
public void Printing2D()
{
Console.WriteLine("X=\t"+X);
Console.WriteLine("Y=\t"+Y);
}
}
class Print3D:Print2D
{
public int X { get; set; }
public int Y { get; set; }
public int Z { get; set; }
public Print3D(int x,int y,int z) : base(x,y)
{
Z = z;
Console.WriteLine("3D");
}
public void Printing3D()
{
base.Printing2D();
Console.WriteLine("Z=\t" + Z);
}
}
class Program
{
static void Main(string[] args)
{
Print3D p3d = new Print3D(4,5,6);
p3d.Printing3D();
}
}
Info Important