扩展并实现相当于在C# [英] extends and implements equivalent in C#

查看:150
本文介绍了扩展并实现相当于在C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是新来的C#的是下面的语句在C#中的等价

 公共类的狮子伸出动物实施日()
{
}
 

解决方案
  • 动物是基类
  • 在日是一个接口

继承可以这样声明。

 公共类金狮:动物,日
{

}
 

C#,你可以继承一个基类,可以有多个接口。

另外一个技巧,如果你正在一个接口在C#中,用 preFIX它,我。例如, IDiurnal

I am new to C# what is the equivalent of following statement in C#

public class Lion extends Animal implements Diurnal()
{
}

解决方案

  • Animal is Base class
  • Diurnal is an Interface

the inheritance could be declared like this.

public class Lion : Animal, Diurnal
{

}

In C#, you can inherit one base class and can be multiple Interfaces.

One more tip, if you are making an Interface in C#, prefix it with I. eg IDiurnal

这篇关于扩展并实现相当于在C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆