当前位置:网站首页>C#接口类的学习
C#接口类的学习
2022-06-09 20:25:00 【charlsdm】
下边是我C#接口类的学习
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp4
{
interface IFly
{
void Fly();
string Name
{
set;
get;
}
int this[int index]
{
get;
set;
}
event Action doSomething;
}
interface IWalk
{
void Walk();
}
interface IMove:IFly,IWalk
{
}
interface IAtk
{
void Atk();
}
interface ISuperAtk
{
void Atk();
}
class Player : IAtk, ISuperAtk
{
void IAtk.Atk()
{
Console.WriteLine("IAtk Attack");
}
void ISuperAtk.Atk()
{
Console.WriteLine("ISuperAtk Attack");
}
public void Atk()
{
Console.WriteLine("PlayerAttack");
}
}
class Test : IMove
{
public int this[int index] {
get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public string Name {
get => throw new NotImplementedException(); set => throw new NotImplementedException(); }
public event Action doSomething;
public void Fly()
{
}
public void Walk()
{
}
}
class Animal
{
}
class Person : Animal, IFly
{
public int this[int index] {
get {
return 0; } set {
} }
public string Name {
get; set; }
public event Action doSomething;
public virtual void Fly()
{
}
}
class Program
{
static void Main(string[] args)
{
IFly f = new Person();
IMove im = new Test();
IFly ifly = new Test();
IWalk iw = new Test();
IAtk ia = new Player();
ISuperAtk isa = new Player();
ia.Atk();
isa.Atk();
Player P = new Player();
//(P as IAtk).Atk();
// (P as ISuperAtk).Atk();
P.Atk();
}
}
}
边栏推荐
猜你喜欢
![[MySQL] principle and construction of master-slave replication](/img/02/c0fec31d55ef20975bd3de2580e8c6.png)
[MySQL] principle and construction of master-slave replication

【RK2206】4. MQTT示例

Not only Lenovo, which sells computers, but also what's new?

MySQL data type

Safety net interview (Miscellaneous)

Leetcode 1984. 学生分数的最小差值(可以,已解决)

Neo4j desktop database backup

Apple Announces Winner of the 2022 Apple Design Award

How did musk become Jindong?

NoSQL之Redis配置与优化(你不在南京的日子我替你吹了秦淮河的晚风)
随机推荐
95 ans plus tard, le programmeur de Big Factory a été condamné à neuf mois de prison pour avoir supprimé la bibliothèque.
Not only Lenovo, which sells computers, but also what's new?
高通:将坚持多元化的代工战略,关注英特尔代工商务合作条件
HMI 联机下载失败的问题及解决方案
Niuke network: some sorting problems about the k-th number
下载最新的全球疫情历史数据,下载到当前日前两天
paramiko和线程池Demo(快速批量操作服务器)
Leetcode 1984. Minimum difference in student scores (yes, resolved)
Query SQL
95後大廠程序員删庫被判刑9個月
Win7 64 bit ultimate installation office2003 prompt: "error 1919, error occurred when configuring ODBC data source MS Access database ODEC error"
UNION ALL UNION FULL JOIN
博文推荐|BookKeeper - Apache Pulsar 高可用 / 强一致 / 低延迟的存储实现
Set creation and traversal methods
如何查看 Tekton 的流水线指标
自动更新域名解析到本机IP,DDNS
Odoo passed ir model. access. CSV modify other module permissions
Target Segmentation -- semantic segmentation of multi category dataset by Unet
HMI 创建工程生成字库的一个潜在bug
More than observation | Alibaba cloud observable Technology Summit officially launched