Книга: C# 2008 Programmer
Abstract Class
Abstract Class
The Shape
class does not specify a particular shape, and thus it really does not make sense for you to instantiate it directly, like this:
Shape someShape = new Shape();
Instead, all other shapes should inherit from this base class. To ensure that you cannot instantiate the Shape
class directly, you can make it an abstract class by using the abstract
keyword:
public abstract class Shape {
//---properties---
public double length { get; set; }
public double width { get; set; }
//---method---
public double Perimeter() {
return 2 * (this.length + this.width);
}
}
Once a class is defined as abstract, you can no longer instantiate it directly; the following is now not permitted:
//---cannot instantiate directly---
Shape someShape = new Shape();
The abstract
keyword indicates that the class is defined solely for the purpose of inheritance; other classes need to inherit from it in order to have objects of this base type.
- Abstract Methods
- Sealed Classes and Methods
- Calling Base Class Constructors
- InterBase Classic Server под Linux
- Каталог BIN в InterBase Classic Server для Linux
- Classic
- Classic vs SuperServer
- Рекомендации по выбору архитектуры: Classic или SuperServer?
- Эффективное взаимодействие процессов архитектуры Classic Server
- Yaffil Classic Server - замена InterBase Classic 4.0
- SERVER PRIORITY CLASS
- CLASSIFY target