Knowledge Management Banner

Knowledge Management Banner

C# : Abstract Vs Interface : Part 12


  • Abstract class can have implementation for some of its members. But interface cannot have implementation for any of its members.
  • Abstract can have fields while interface cannot have fields.
  • Abstract class can inherit from any other abstract class or interface, where as interface can inherit only from interface.
  • Abstract class members can have modifiers where as interface class members cannot have modifiers.
e.g.

//Interface example

    public interface Interface1
    {
        void AddNumbers(int a, int b);
    }

//Abstract class example
    public abstract class Abstract1
    {
        public abstract int AddNumbers(int a, int b);
    }

No comments

Powered by Blogger.