Results 1 to 4 of 4

Thread: Abstract class situation to use

  1. #1

    Thread Starter
    Fanatic Member karthikeyan's Avatar
    Join Date
    Oct 2005
    Location
    inside .net
    Posts
    919

    Abstract class situation to use

    I tried to get knowledge on when to use abstact class and when to use interface. i found some explanaiton in the below path.

    http://msdn.microsoft.com/en-us/libr...1d(VS.71).aspx

    If you anticipate creating multiple versions of your component, create an abstract class. Abstract classes provide a simple and easy way to version your components. By updating the base class, all inheriting classes are automatically updated with the change. Interfaces, on the other hand, cannot be changed once created. If a new version of an interface is required, you must create a whole new interface.

    So is there any sample code which demostrate this differnece in using? please share with me so that i will get very good clarity on situation to use this. please
    Loving dotnet

  2. #2
    Frenzied Member Lightning's Avatar
    Join Date
    Oct 2002
    Location
    Eygelshoven
    Posts
    1,611

    Re: Abstract class situation to use

    The difference can't be shown in code, you have to understand them. First of all, an interface has no functionality, it describes which properties and methods a class, implementing the interface, at least has. An abstract class can have functionality.
    If the functionality is used by external parties, you should write an interface and never change that interface again, for internal use an abstract class can be changed
    VB6 & C# (WCF LINQ) mostly


    If you need help with a WPF/WCF question post in the NEW WPF & WCF forum and we will try help the best we can

    My site

    My blog, couding troubles and solutions

    Free online tools

  3. #3
    PowerPoster
    Join Date
    Aug 2003
    Location
    Edinburgh, UK
    Posts
    2,773

    Re: Abstract class situation to use

    to elaborate on the existing response: interfaces cannot be instantiated but only implemented in classes. they also must implement all methods or properties exposed in the interface and is public.

    abstract classes may contain some code/functionality and has the option of letting the deriving classes override members or methods in the base class/abstract class and acts as a foundation for all classes, combining common features in the abstract class from which the inheriting classes can derive from and call to perform some action.

    MVP 2007-2010 any chance of a regain?
    Professional Software Developer and Infrastructure Engineer.

  4. #4

    Thread Starter
    Fanatic Member karthikeyan's Avatar
    Join Date
    Oct 2005
    Location
    inside .net
    Posts
    919

    Re: Abstract class situation to use

    thank you guys.
    Loving dotnet

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width