Thursday, November 25, 2010

Using Abstract Classes in C#.

C# enables you to create abstract classes that are used to provide partial class implementation of an interface. You can complete implementation by using the derived classes. Abstract classes contain abstract methods, which can be implemented by the derived class. Polymorphism can be implemented by using abstract classes and virtual functions. When you create derived classes, you provide more specialized functionality; polymorphism enables you to treat the new objects as general objects.

The following code is an example of the declaration of an abstract class:

Abstract class ExampleAbstract

// This is an abstract class

{
……………….

}

class TestAbstract
{
Static Void Main (String[] args)
{
ExampleAbstract obj = new ExampleAbstract ();
//abstract class cannot be instantiated
}
}

NOTE: - abstract class is created by using the abstract keyword. There are certain rules governing the use of an abstract class.

The rules are:
Cannot create an instance of an abstract class.
Cannot declare an abstract method outside an abstract class.
Cannot be declared sealed.

1 comment:

shipra sagar said...

Hello all,I am new and I would like to ask that what are the benefits of sql training,What all topics should be covered in it?
And has anyone studied from this course http://www.wiziq.com/course/2118-learn-how-to-program-in-c-language of C tutorial online?? or tell me any other guidance...
would really appreciate help

Recent Posts