Difference Between Abstract Class And Interface :
2. Abstract classes can have implementations for some of its members(methods) but the interface can't have implementation for any of its members.
1. An abstract class doesn't provide full abstraction but an interface does provide full abstraction.
x
x
2. Abstract classes can have implementations for some of its members(methods) but the interface can't have implementation for any of its members.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace Abstarct_Interface
{
public partial class AbstractInterface : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
public abstract class Customer
{
int i = 1; //Build Sucess
public void print() //Abstract class members have private
{
Console.WriteLine("Hellow my
world");
}
}
public interface Icustomer
{
int i = 1; //can not build getting error
//public void Print1();
//{
//
Console.WriteLine("hi");
//}
}
}
}
3.Interface cannot have fields where as an abstract class can have fields.
4. An interface can inherit from another interface only and can not inherit from an abstract class,
where as an abstract class can inherit from another abstract class or another interface.
5. A class can inherit from multiple interface at the same time where as a class cannot inherit from multiple classes at the same time.
6. Abstract class members can have access modifiers where as interface members cannot have access modifiers.
3.Interface cannot have fields where as an abstract class can have fields.
4. An interface can inherit from another interface only and can not inherit from an abstract class,
where as an abstract class can inherit from another abstract class or another interface.
5. A class can inherit from multiple interface at the same time where as a class cannot inherit from multiple classes at the same time.
6. Abstract class members can have access modifiers where as interface members cannot have access modifiers.