Professional Documents
Culture Documents
08 Interface
08 Interface
Chng 8:
Lp trnh Web
Ni dung
Interface
Lp trnh Web
Interface
nh ngha Interface
Lp trnh Web
nh ngha Interface
Interface ging nh l mt lp c s o thun ty.
phn thn ca method Mt class hoc struct m thc thi mt interface th phi nh ngha phn thn ca tt c cc method trong interface . Khng th to instance ca mt interface.
Lp trnh Web
V d khai bo interface
interface IStoreable { void Read(); void Write(); int Status { get; set; } }
Lp trnh Web
class Tester { static void Main(string[] args) { MyStore objMyStore = new MyStore(); objMyStore.Read(); IStoreable iStoreable = objMyStore; iStoreable.Read(); }
Lp trnh Web
V d: class MyClass : IMyInterface1,IMyInterface2{} Mt class thc thi interface no th n phi implement tt c cc phng thc khai bo trong interface .
Lp trnh Web