Windows Phone Developers

Friday, December 5, 2008

Abstract Methods in .NET (C#)

An abstract method is a virtual method with no implementation. The actual implementation of the abstract method will be from a overridden method of the derived class.

An abstract method is declared with the abstract modifier and is permitted only in a class that is also declared abstract.

public abstract class AbsExample {

public abstract string AbsMethod();

}

An abstract method must be overridden in every non-abstract derived class.

class AbsImplementor : AbsExample

{

public override string AbsMethod()

{

return "AbsMethod Implemented!!!";

}

}

The method can be invoked by

AbsImplementor a1 = new AbsImplementor();

Console.WriteLine(a1.AbsMethod());

Digg Technorati Delicious StumbleUpon Reddit BlinkList Furl Mixx Facebook Google Bookmark Yahoo
ma.gnolia squidoo newsvine live netscape tailrank mister-wong blogmarks slashdot spurl StumbleUpon

No comments:

Post a Comment

kbAlertz.com :: Visual Studio 2005

kbAlertz.com :: Visual Studio 2008

kbAlertz.com :: Visual Basic 2005