C# .NET - difference between abstractclass and interface

Asked By Durga Devi on 01-Mar-06 01:16 AM
Hai every body i am getting a little bit cofusion about the difference between abstract class and interface when we use abstract class and interfaces.
please suggest me about this.
Thanking u

Abstract vs Interface

Asked By Shallu Gupta on 01-Mar-06 01:28 AM
You cannot create an object of abstract class , but can make derivations of this.
An abstract class can contain either abstract methods or non abstract methods. Abstract members do not have any implementation in the abstract class, but the same has to be provided in its derived class.
An abstract class can have abstract members as well non abstract members. But in an interface all the members are implicitly abstract and all the members of the interface must override to its derived class.
Defining an abstract class with all the abstract members is similar to defining an interface. i.e we can say an interface is an abstract class with all the abstract members
Refer msdn difference for more info..
http://msdn.microsoft.com/msdnmag/issues/03/12/CQA/

difference between abstractclass and interface

Asked By Pankaj Sharma on 01-Mar-06 02:00 AM
Interfaces are closely related to abstract classes that have all members abstract.
 For an abstract class, at least one method of the class must be an abstract method that means it may have concrete methods.
 For an interface, all the methods must be abstract
 Class that implements an interface much provide concrete implementation of all the methods definition in an interface or else must be declare an abstract class
 In C#, multiple inheritance is possible only through implementation of multiple interfaces. Abstract class can only be derived once.
 An interface defines a contract and can only contains four entities viz methods, properties, events and indexes. An interface thus cannot contain constants, fields, operators, constructors, destructors, static constructors, or types.
 Also an interface cannot contain static members of any kind. The modifiers abstract, public, protected, internal, private, virtual, override is disallowed, as they make no sense in this context.
 Class members that implement the interface members must be publicly accessible.
For further reading check 
http://www.c-sharpcorner.com/Code/2003/Dec/OOPS%20In%20CSharp%201.0.asp
premkumar replied to Durga Devi on 23-Aug-10 06:04 AM
 Absract class contains implemented and non-implemented methods . If non-implemented methods , the method should contain 'abstract' keyword. The Base class only be a Abstract Class.If a subclass extends abstract class,that subclass shoul implement the all nonimplemented methods in abstract base class.

Interface came for satisfy the multithreading concept.Interface should contains COnstant Variable and non implemented methods.Those methods are implicitly abstract. Interface can inherit more than one interface.If a class implement a interface  doesnot implement anyone of the nonimplemented method of that interface, then the class becomes an abstract class.