C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !




Abstract Class Concept


Posted Date: 02 Aug 2006    Resource Type: Articles    Category: .NET Framework

Posted By: DotNetGuts (DNG)       Member Level: Diamond
Rating:     Points: 10



Abstract Class



1) Abstract class defines functionality that is implemented by one or more subclass.
2) Abstract class states “what” to do, rather than “how” to do.
3) Abstract class cannot be instantiated.
4) Abstract method “must” be overridden in derived class.
5) Abstract classes can provide all, some, or none of the actual implementation of a class. It provides a default code or stub for their child class.
6) It is useful while creating Component.

Eg:

abstract class shape
{
void draw() { }
}

class circle : shape
{
void draw()
{
Console.WriteLine(“Circle”);
}
}

class rectangle : shape
{
void draw()
{
Console.WriteLine(“rectangle”);
}
}

class triangle : shape
{
void draw()
{
Console.WriteLine(“triangle”);
}
}

static void main()
{
shape s;
s = new circle();
s.draw();
s = new rectangle();
s.draw();
s = new triangle();
s.draw();
}
//Output
circle
rectangle
triangle


Abstract classes may contain constructors. When we can't instantiate the abstract classes, what is the use of these constructors?

A constructor of a class is not only called when its object is instantiated; it also gets called when an object of its subclass is created. So, an abstract class may contain a constructor to be called when it subclass is instantiated.




Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Abstract Class  .  

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: Understanding concept of "ref" and "out" keyword in Dot Net
Previous Resource: Dynamic Tool Tip in webapplications
Return to Discussion Resource Index
Post New Resource
Category: .NET Framework


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

doors in nj

Contact Us    Privacy Policy    Terms Of Use