C# Interface的使用方法探讨
public class FuckBase
{
public void FuckSomething(int fuck)
{ }
} public class Fuck :FuckBase, A
{
public int AInt
{
get;
private set;
} public void DoSomething()
{ }
}
public interface A
{
void DoSomething();
} public interface DeriveedA: A
{
new void DoSomething();
}
public interface DeriveedA: A
{
new void DoSomething();
int AInt { get; set; }
}
public interface DeriveedA: A
{
new void DoSomething();
int AInt { get; }
} public class Fuck : DeriveedA
{
public int AInt
{
get;
private set;//当然了这里也可以是protected
} public void DoSomething()
{ }
}
public class Starter
{
/// <summary>
/// 程序入口点
/// </summary>
/// <param name="args"></param>
public static void Main(string[] args)
{
Fuck test = new Fuck();
}
} public interface IFuck
{
void Haha();
} public class Fuck :IFuck
{
void IFuck.Haha()
{ }
}
public class Starter
{
/// <summary>
/// 程序入口点
/// </summary>
/// <param name="args"></param>
public static void Main(string[] args)
{
Fuck test = new Fuck();
IFuck interfaceFuck = (IFuck)test;
interfaceFuck.Haha();//这个时候相当于可以使用test.Haha这个方法了
}
} public interface IFuck
{
void Haha();
} public class Fuck :IFuck
{
void IFuck.Haha()//注意显式实现接口不能带访问修饰符
{ }
}
public class Starter
{
/// <summary>
/// 程序入口点
/// </summary>
/// <param name="args"></param>
public static void Main(string[] args)
{
Flys fly = new Flys();
IFlyB flyB = fly;
flyB.Cost();//计算航班B的价格 IFlyC flyC = fly;
flyC.Cost();//计算航班C的价格 fly.Cost();//计算普通航班的价格 Console.ReadKey();
}
}
public interface IFlyB
{
void Cost();
} public interface IFlyC
{
void Cost();
} public class Flys :IFlyB,IFlyC
{
public void Cost()
{
Console.WriteLine("Other fly");
} void IFlyB.Cost()
{
Console.WriteLine("Fly B");
} void IFlyC.Cost()
{
Console.WriteLine("Fly C");
}
}

class Flys
{
public:
virtual void cost()const =
{
std::cout << "Other fly" << std::endl;
}
}; class FlyB :public Flys
{
public:
void cost()const override
{
std::cout << "FlyB" << std::endl;
}
}; class FlyC :public Flys
{
public:
void cost()const override
{
std::cout << "FlyC" << std::endl;
}
}; class OtherFly :public Flys
{
public:
void cost()const override
{
Flys::cost();
}
};
public interface IOne
{
int Item { get; set; }
} public interface ITwo
{
int Item();
} public class Hey : IOne, ITwo
{
public int Item { get; set;} public int Item()
{
throw new NotImplementedException();
}
}
public interface IOne
{
int Item { get; set; }
} public interface ITwo
{
int Item();
} public class Hey : IOne, ITwo
{
public int Item { get; set;} int ITwo.Item()
{ }
}
public class ListNode<T> : IList<T>
{
public T RemoveAt(int index)
{ } void IList<T>.RemoveAt(int index)
{ }
}
C# Interface的使用方法探讨的更多相关文章
- as3.0 interface接口使用方法
[转]as3.0 interface接口使用方法 AS在2.0的时候就支持接口了 接口能够让你的程序更具扩展性和灵活性,打个例如 比方你定义了一个方法 代码: public function aMet ...
- 关于Oracle本地连接出现与监听有关的问题的解决方法探讨
关于Oracle本地连接出现与监听有关的问题的解决方法探讨 监听的作用: 用于应用桌面即用户与数据库服务器建立连接的媒介,客户端发送连接请求,监听识别请求并建立客户端与服务器的连接后,监听的使命并完成 ...
- GO学习-(38) Go语言结构体转map[string]interface{}的若干方法
结构体转map[string]interface{}的若干方法 本文介绍了Go语言中将结构体转成map[string]interface{}时你需要了解的"坑",也有你需要知道的若 ...
- 关于java8 interface的default方法
转自鸟窝 博主写的挺详细,不了解的看一看啊 以前经常谈论的Java对比c++的一个优势是Java中没有多继承的问题. 因为Java中子类只能继承(extends)单个父类, 尽管可以实现(implem ...
- WebGIS中前端JS生成等值面方法探讨
文章版权由作者李晓晖和博客园共有,若转载请于明显处标明出处:http://www.cnblogs.com/naaoveGIS/ 1.背景 在之前的博文<WebGIS中等值面展示的相关方案简析&g ...
- 可前端解密的加密方法探讨和str_replace和preg_replace分析
目的: 对字符串‘123456’进行后端加密,前端js可解密出真实字符 测试代码php: static $hashMap = array( '0' => '4', '1' => '9', ...
- Android平台Camera实时滤镜实现方法探讨(三)--通过Shader实现YUV转换RBG
http://blog.csdn.net/oshunz/article/details/50055057 文章例如该链接通过将YUV分成三个纹理,在shader中取出并且经过公式变换,转换成RGB.我 ...
- Android平台Camera实时滤镜实现方法探讨(九)--磨皮算法探讨(一)
上一篇开头提到了一些可用于磨皮的去噪算法.以下我们实现这些算法而且观察效果,咱不考虑实时性的问题 本文首先探讨的首先是<基于局部均方差相关信息的图像去噪及其在实时磨皮美容算法中的应用> 该 ...
- js 中读取JSON的方法探讨
方法一:函数构造定义法返回 var strJSON = "{name:'json name'}"; //得到的JSONvar obj = new Function("r ...
随机推荐
- Tween公式 以及四个参数
Tween的主页在这里:http://createjs.com/tweenjs , 这里边还有挺多开源项目的: Tween公式 4个参数 t:current time(当前时间) b:beginnin ...
- 聊聊 Apache 开源协议
摘要 用一句话概括 Apache License 就是,你可以用这代码,但是如果开源你必须保留我写的声明:你可以改我的代码,但是如果开源你必须写清楚你改了哪些:你可以加新的协议要求,但不能与我所 公布 ...
- 报错:MySQL check the manual that corresponds to your MySQL server version for the right syntax
今天在向MySQL中插入数据时,报了标题的错误,因为我用的是session.save(object)方法,后台打印出的object和sql语句都没有问题,后来在网上查询,发现http://blog.c ...
- Oracle存储过程由例子到理论
1.基础环境 oracle HR环境添加新表 CREATE TABLE "HR"."cus_test" ( "id" BYTE) NOT N ...
- BZOJ 1221: [HNOI2001] 软件开发
1221: [HNOI2001] 软件开发 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1428 Solved: 791[Submit][Stat ...
- CodeForces - 696B Puzzles
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
- js中网页区域/正文/屏幕 宽和高
网页可见区域宽: document.body.clientWidth; 网页可见区域高: document.body.clientHeight; 网页可见区域宽: document.body.offs ...
- JQ-动画合集(ing...)
一:给向上按钮加动画,让页面卷回上面而不是生硬跳转.js $('#topBtn').click(function(){ $('html,body').animate({scrollTop: '0px' ...
- PHPCMS导航栏当前栏目选中方法
{if $top_parentid==0}<!--判断首页显示的是不是首页--> <li><a href="{siteurl($siteid)}" s ...
- Python之路【第二十三篇】爬虫
difference between urllib and urllib2 自己翻译的装逼必备 What is the difference between urllib and urllib2 mo ...