Abstract and Sealed Classes and Class Members (C# Programming Guide)
The abstract keyword enables you to create classes and class members that are incomplete and must be implemented in a derived class.
The sealed keyword enables you to prevent the inheritance of a class or certain class members that were previously marked virtual.
Classes can be declared as abstract by putting the keyword abstract before the class definition. For example:
public abstract class A
{
// Class members here.
}
An abstract class cannot be instantiated. The purpose of an abstract class is to provide a common definition of a base class that multiple derived classes can share. For example, a class library may define an abstract class that is used as a parameter to many of its functions, and require programmers using that library to provide their own implementation of the class by creating a derived class.
Abstract classes may also define abstract methods. This is accomplished by adding the keyword abstract before the return type of the method. For example:
public abstract class A
{
public abstract void DoWork(int i);
}
important Notes:
(a)Any Class with abstract method or property in it must be declared abstract
(b)Attempting to instantiate an object of an abstract class retults in a compilation error
Abstract methods have no implementation, so the method definition is followed by a semicolon instead of a normal method block. Derived classes of the abstract class must implement all abstract methods. When an abstract class inherits a virtual method from a base class, the abstract class can override the virtual method with an abstract method. For example:
// compile with: /target:library
public class D
{
public virtual void DoWork(int i)
{
// Original implementation.
}
}
public abstract class E : D
{
public abstract override void DoWork(int i);
}
public class F : E
{
public override void DoWork(int i)
{
// New implementation.
}
}
If a virtual method is declared abstract, it is still virtual to any class inheriting from the abstract class. A class inheriting an abstract method cannot access the original implementation of the method—in the previous example, DoWork on class F cannot call DoWork on class D. In this way, an abstract class can force derived classes to provide new method implementations for virtual methods.
Abstract classes normally contain one or more abstract methods or abstract properties, such methods or properties do not provide implementations, but our derived classes must override inherited abstract methods or properties to enable obejcts ot those derived classes to be instantiated, not to override those methods or properties in derived classes is syntax error, unless the derived class also is an abstract class
Sealed Classes and Class Members
Classes can be declared as sealed by putting the keyword sealed before the class definition. For example:
public sealed class D
{
// Class members here.
}
A sealed class cannot be used as a base class. For this reason, it cannot also be an abstract class. Sealed classes prevent derivation. Because they can never be used as a base class, some run-time optimizations can make calling sealed class members slightly faster.
A class member, method, field, property, or event, on a derived class that is overriding a virtual member of the base class can declare that member as sealed. This negates the virtual aspect of the member for any further derived class. This is accomplished by putting the sealed keyword before the override keyword in the class member declaration. For example:
public class D : C
{
public sealed override void DoWork() { }
}
Classes and Structs (C# Programming Guide)
Classes and structs are two of the basic constructs of the common type system(CTS) in the .NET Framework
C# Programming Guide
http://msdn.microsoft.com/en-us/library/67ef8sbd.aspx
The abstract keyword enables you to create classes and class members that are incomplete and must be implemented in a derived class.
The sealed keyword enables you to prevent the inheritance of a class or certain class members that were previously marked virtual.
Classes can be declared as abstract by putting the keyword abstract before the class definition. For example:
public abstract class A
{
// Class members here.
}
An abstract class cannot be instantiated. The purpose of an abstract class is to provide a common definition of a base class that multiple derived classes can share. For example, a class library may define an abstract class that is used as a parameter to many of its functions, and require programmers using that library to provide their own implementation of the class by creating a derived class.
Abstract classes may also define abstract methods. This is accomplished by adding the keyword abstract before the return type of the method. For example:
public abstract class A
{
public abstract void DoWork(int i);
}
important Notes:
(a)Any Class with abstract method or property in it must be declared abstract
(b)Attempting to instantiate an object of an abstract class retults in a compilation error
Abstract methods have no implementation, so the method definition is followed by a semicolon instead of a normal method block. Derived classes of the abstract class must implement all abstract methods. When an abstract class inherits a virtual method from a base class, the abstract class can override the virtual method with an abstract method. For example:
// compile with: /target:library
public class D
{
public virtual void DoWork(int i)
{
// Original implementation.
}
}
public abstract class E : D
{
public abstract override void DoWork(int i);
}
public class F : E
{
public override void DoWork(int i)
{
// New implementation.
}
}
If a virtual method is declared abstract, it is still virtual to any class inheriting from the abstract class. A class inheriting an abstract method cannot access the original implementation of the method—in the previous example, DoWork on class F cannot call DoWork on class D. In this way, an abstract class can force derived classes to provide new method implementations for virtual methods.
Abstract classes normally contain one or more abstract methods or abstract properties, such methods or properties do not provide implementations, but our derived classes must override inherited abstract methods or properties to enable obejcts ot those derived classes to be instantiated, not to override those methods or properties in derived classes is syntax error, unless the derived class also is an abstract class
Sealed Classes and Class Members
Classes can be declared as sealed by putting the keyword sealed before the class definition. For example:
public sealed class D
{
// Class members here.
}
A sealed class cannot be used as a base class. For this reason, it cannot also be an abstract class. Sealed classes prevent derivation. Because they can never be used as a base class, some run-time optimizations can make calling sealed class members slightly faster.
A class member, method, field, property, or event, on a derived class that is overriding a virtual member of the base class can declare that member as sealed. This negates the virtual aspect of the member for any further derived class. This is accomplished by putting the sealed keyword before the override keyword in the class member declaration. For example:
public class D : C
{
public sealed override void DoWork() { }
}
Classes and Structs (C# Programming Guide)
Classes and structs are two of the basic constructs of the common type system(CTS) in the .NET Framework
C# Programming Guide
http://msdn.microsoft.com/en-us/library/67ef8sbd.aspx