14-10-12, 03:48 PM
كاتب الموضوع : أحمد جمال
بسم الله الرحمن الرحيم .السلام عليكم ورحمة الله وبركاته .
تعريف ال Interface :
ال interface هو abstract class يحتوي على abstract mehods and members يمكن عمل نسخة منه باستخدام بمفهوم implementation بدلاً من inhiritancae ، كما يتميز بامكانية عمل implement لاكثر من interface في المرة الواحدة وهو البديل عن مفهوم multiple inhiritance .
يمكن تعريف interface بالشكل التالي مثلاً :
C#:
كود :
public interface ICar
{
int carMaxSpeed{get;set;}
void AddItem(string Item);
}
كود :
Public Interface ICar
Property carMaxSpeed() As Integer
Sub AddItem(ByVal Item As String)
End Interface
C#:
كود :
public interface ICar:IDisposable
{
int carMaxSpeed{get;set;}
void AddItem(string Item);
}
كود :
Public Interface ICar
Inherits IDisposable
Property carMaxSpeed() As Integer
Sub AddItem(ByVal Item As String)
End Interface
C#:
كود :
public class BMW : Car
{
}
public class BMW2 : Car, Truck
{
}
كود :
Public Class BMW
Implements Car
End Class
Public Class BMW2
Implements Car, Truck
End Class