c# interface介面
using System;
using System.Collections.Generic;
using System.Text;
namespace learninterface1
{
//類繼承多個介面,繼承介面可能是父子介面關係
//類必須實現介面的所有成員
class Program:Imyinterface1,Iman
{
string name;
public string NAME
{
get
{
return name;
}
set
{
name = value;
}
}
string shiye;
public string SHIYE
{
get
{
return shiye;
}
set
{
shiye = value;
}
}
public void ShowInfo()
{
Console.WriteLine("姓名");
Console.WriteLine(NAME);
Console.ReadKey();
}
public void ManDo()
{
Console.WriteLine("子介面iman的方法mando");
}
static void Main(string[] args)
{
Program p = new Program();
//透過介面物件例項化,呼叫
Imyinterface1 i1 = p;
i1.NAME = "zxy";
i1.ShowInfo();
Iman im1=p;
im1.NAME = "oth";
im1.SHIYE = "shiye1";
im1.ManDo();//例項化介面物件時(子介面時,它有父介面,即介面是繼承關係)
Program p1 = new Program();
p1.name = "ha1";
p1.ShowInfo();
}
}
}
using System;
using System.Collections.Generic;
using System.Text;
namespace learninterface1
{
interface Imyinterface1
{
string NAME
{
get;
set;
}
void ShowInfo();
}
//接品繼承介面,子介面不用重寫父介面的成員,僅編寫新增的成員即可
interface Iman:Imyinterface1
{
string SHIYE
{
get;
set;
}
void ManDo();
}
}
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/9240380/viewspace-718287/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 瞭解下C# 介面(Interface)C#
- interface/介面
- public interface View介面和public interface ViewResolver介面介紹View
- 如何理解 interface 介面
- Java-介面(interface)Java
- firewalld: 介面interface操作
- java中的interface(介面)Java
- go sort.Interface 排序介面Go排序
- C#-介面(Interface)詳解C#
- Interface(介面分享)第一節
- interface 介面 -Go 學習記錄Go
- Golang 學習——interface 介面學習(一)Golang
- Golang 學習——interface 介面學習(二)Golang
- PLC結構化文字(ST)——介面(Interface)
- 什麼是Java Marker Interface(標記介面)Java
- SAP系統裡的胖介面Fat interface
- SAP ABAP Netweaver裡的胖介面(fat interface)
- 使用Golang的interface介面設計原則Golang
- PHP中的 抽象類(abstract class)和 介面(interface)PHP抽象
- 藉助 zope.interface 深入瞭解 Python 介面Python
- C#介面配置C#
- 【Golang】Go 通過結構(struct) 實現介面(interface)GolangStruct
- API(Application Programming Interface,應用程式程式設計介面)APIAPP程式設計
- 登入介面(C#)C#
- Java深海拾遺系列(5)---函式式介面Functional InterfaceJava函式Function
- Golang | 既是介面又是型別,interface是什麼神仙用法?Golang型別
- C#內建介面:IEnumerableC#
- C#介面卡模式C#模式
- struct 和 interface:結構體與介面都實現了哪些功能?Struct結構體
- The ArrayAccess interface
- C# 8: 預設介面方法C#
- C#基礎之介面(6)C#
- C# 訊息 介面卡頓 介面程序 工作程序C#
- golang使用sqlx報錯:unsupported type []interface {}, a slice of interfaceGolangSQL
- C#快速入門教程(16)—— 介面C#
- Interface中加Static
- Golang之interfaceGolang
- c#中介面卡模式詳解C#模式
- Unity3D C#建立COM介面Unity3DC#