Posted by: Zeeshan Amjad | July 13, 2009

Hello world!


Hello world. I started this blog to share my experience specially the technical one. To kick off the discussion let’s start with a very simple topic the abstract class in C#. In C++ to make abstract class one has to write pure virtual function and derived class has to override this to make an object of it. C# introduces one keyword “abstract” to make it more readable.  In C# one can use the abstract keyword with the class without making any of its function abstract. In other words one can make a abstract class in C# without making any of its method abstract. Let’s see one example from the .Net framework itself. Almost all of the WPF classes are inherited from a “DispatcherObject” class. This is an abstract class without making any of its function abstract. If we just inherit one class from it then it is a concrete class without overriding any method. Here is an example of it.

public class MyDispatcher : DispatcherObject
{
}

MyDispatcher is not an abstract class and one can create an object of it just like any other object. There is one more abstract class in WPF name Visual. This is also same as MyDispatcher i.e. abstract class without any abstract method. This is very interesting and powerful concept on C#.

Advertisements

Responses

  1. Congrats on posting your first blog post. 🙂


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: