Properties:Virtual Properties
/*
A Programmer's Introduction to C# (Second Edition)
by Eric Gunnerson
Publisher: Apress L.P.
ISBN: 1-893115-62-3
*/
// 18 - Properties\Virtual Properties
// copyright 2000 Eric Gunnerson
using System;
public abstract class DrawingObject
{
public abstract string Name
{
get;
}
}
class Circle: DrawingObject
{
string name = "Circle";
public override string Name
{
get
{
return(name);
}
}
}
public class PropertiesVirtualProperties
{
public static void Main()
{
DrawingObject d = new Circle();
Console.WriteLine("Name: {0}", d.Name);
}
}
Related examples in the same category