C#中隐式接口与显示接口
来源:互联网 发布:淘宝7.1.0版本官方网 编辑:程序博客网 时间:2024/04/28 10:27
C#中隐式接口与显示接口
隐式接口:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
namespace ConsoleApplication1
{
public interface Animal
{
void talk();
}
public class Dog:Animal
{
public void talk() //区别
{
Console.WriteLine("狗");
}
}
class Program
{
static void Main(string[] args)
{
var temp = new Dog();
temp.talk();
Console.ReadKey();
}
}
}
显示接口:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Collections;
namespace ConsoleApplication1
{
public interface Animal
{
void talk();
}
public class Dog:Animal
{
void Animal.talk() //区别
{
Console.WriteLine("狗");
}
}
class Program
{
static void Main(string[] args)
{
//错误
//var temp = new Dog();
//temp.talk();
//正确
Animal temp = new Dog();
temp.talk();
Console.ReadKey();
}
}
}
Why:
有的时候一个类会继承好几个接口,接口的名字可能会冲突,这个时候显示接口就派上用场了。
- C#中隐式接口与显示接口
- C# 接口,显示实现接口
- C# 中 显示实现接口 与 隐式实现接口
- C#接口的显示与隐式
- C#接口显示实现
- C# 接口 与 java 接口
- C# 显示接口和隐式接口
- C# 接口与工厂
- C#之类与接口
- C# 类与接口
- C#泛型类与接口
- C# 类与接口
- C# 接口的隐式与显示实现
- C# 接口的隐式与显示实现
- 【转】C# 接口的隐式与显示实现
- C# 接口的隐式与显示实现
- C# 接口的隐式与显示实现
- C# 接口的隐式与显示实现
- POJ 1328 Radar Installation (贪心)
- 英语语法 可作主语的词类 1.1.1名词作主语
- POJ1459 Power Network【最大流】【Edmond-Karp】
- HDU1394 Minimum Inversion Number 线段树+数学
- 三国群英传——哪些官职可以不封?
- C#中隐式接口与显示接口
- 在iOS7以后的状态栏设置样式
- HTML颜色代码表
- (1185)POJ-状态压缩
- 黑马程序员——java高新技术--反射
- Swift 复数变量定义
- 改变自己,带动激情,让人生更有意义
- iOS app在启动过程的设置图片的规格
- 英语语法 可作主语的词类 1.1.2代词作主语