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



My Profile

Gifts

Active Members
TodayLast 7 Days more...







in abstract classes why we should use mustinherit keyword?


Posted Date: 26 Aug 2006      Total Responses: 2

Posted By: sirishpyata       Member Level: Silver     Points: 2


hi all,
In abstract classes why we should use mustinherit keyword?& why we should override &MustOverride .plz explain in detail. with some examples in real time.




Responses

Author: shivi purwar    26 Aug 2006Member Level: BronzeRating:     Points: 2
Abstract (MustInherit) Classes
Abstract classes can simply defined as incomplete classes.

Abstract (MustInherit) classes contain one or more incomplete methods called abstract (MustOverride) methods.
The abstract (MustInherit) class only provides the signature or declaration of the abstract (MustOverride) methods and leaves the implementation of these methods to the derived or sub-classes.
1.Abstract classes are marked with MustInherit and abstract methods are marked with the MustOverride keyword
2.Since abstract classes are incomplete; they can not be instantiated. They must be sub-classed in order to use their functionality. This is the reason why an abstract class can't be NotInheritable
3.A class inheriting an abstract class must implement all the abstract methods in the abstract class or it must also be declared as an MustInherit class.
4.A class inheriting an abstract class and one that implements all its abstract methods is called a concrete class of that abstract class.
5.We can declare a reference of the type of abstract class and it can point to the objects of classes that have inherited the abstract class.
MustInherit Class TaxCalculator
Protected mItemPrice As Double
Protected mTax As Double

' an abstract (MustOverride) function
Public MustOverride Function CalculateTax() As Double

' Two concrete properties
Public ReadOnly Property Tax() As Double
Get
Return Tax
End Get
End Property

Public ReadOnly Property ItemPrice() As Double
Get
Return ItemPrice
End Get
End Property
End Class


Author: DotNetGuts (DNG)    26 Aug 2006Member Level: DiamondRating:     Points: 2
All abstract method needs to override in subclass and so u hv to write


Post Reply
You must Sign In to post a response.
Next : in abstract classes why we should use mustinherit keyword?
Previous : Deleting columns from DataTable
Return to Discussion Forum
Post New Message
Category: .NET

Related Messages



dotNet Slackers   BizTalk Adaptors    Web Design

it support

Contact Us    Privacy Policy    Terms Of Use