c#中的实时示例界面 [英] Real Time Example interface in c#

查看:117
本文介绍了c#中的实时示例界面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

请提供任何实时示例。和编码的例子我无法理解theroy ..... plz plz我研究了很多时间我无法理解...........

解决方案

同意Sergey Alexandrovich Kryukov。

但是你可以看到这个评论

界面的实时示例 [ ^ ]


Quote:

我无法理解 theroy

就像你的日常Todo列表一样。考虑一下星期六在星期日任务中列出的物品清单。

<前郎=文字> 0)健身房
1)购物
2)电影
3)自行车服务中心
4)比萨饼



现在,您在周日的行动如下。

 0)前往服务中心进行自行车维修小事 - 上午07:00 
1)步行去健身房,没骑自行车 - 07:30 AM
到家从服务中心骑自行车后。
2)和朋友一起去看电影 - 上午11:00
3)购买GF - 04:00 PM
4)晚餐@Pizza商场 - 08:00 PM



同样,您可以在Interface&稍后使用Interface在类中实现。你可以在Codeproject上找到关于这个主题的一堆文章。


嗯,在客户端 - 服务器架构中,接口是客户端和服务器之间的契约(即协议) 在服务器端实现,并告诉客户端它包含的内容。示例可以是 RMI



一个界面可以由多个类实现,这就是为什么你可以有该接口的多种 实例。



例如,在.NET中 object 是所有其他类的基类,甚至也是用户定义的。

这个对象类实现了包含Equals()等4种方法的接口, ToString(),GetType()和GetHashCode()。您可以在此处找到更多信息[ ^ ]。



我们来谈谈 ToString()。您可以在应用程序中找到此方法中的每个该死的对象。例如,你可以获得int,float,double和/或用户定义对象的String格式。但问题是如何区分哪个ToString()适用于int,哪个用于double,哪个用于float?



所以答案就是这些包装器,即 Int,Double,Float等类有实现的对象接口,每个可能有不同的ToString()工具。



在这种情况下,你需要一个接口。让我们在你的应用程序中说,5个类几乎有相同的方法,但工作方式不同,所以你可以创建一个接口,由这5个类实现并可以使用它。



一些例子,

http://msdn.microsoft.com/en-us/library /87d83y5b.aspx [ ^ ]



[ ^ ]

http://www.onlinebuff.com/ article_implementing-interface-in-c-with-an-example_18.html [ ^ ]

http://www.c-sharpcorner.com/UploadFile/sekarbalag/interface-best-example-in-csharp/ [ ^ ]

http://www.c-sharpcorner.com/UploadFile/sekarbalag/interface-best-example-in-csharp/ [ ^ ]



希望这会对你有所帮助。



-KR

Please give any real time example. and coding example i cann't understand theroy..... plz plz i studied lot of time i cann't understand...........

解决方案

Agree with Sergey Alexandrovich Kryukov.
But you can read this comments
Real time example of interface[^]


Quote:

i cann't understand theroy

It's just like your everyday Todo list. Consider you have list of items on your Sunday Tasks which you made on Saturday.

0) Gym
1) Shopping
2) Movie
3) Service center for Bike
4) Pizza


Now, your actions on Sunday like below.

0) Going to Service center for Bike repair minor things - 07:00 AM
1) Going to Gym by walk as no bike to ride              - 07:30 AM
And reach home after riding bike from Service center.
2) Going to movie with friends                          - 11:00 AM
3) Shopping with GF                                     - 04:00 PM
4) Night dinner @ Pizza mall                            - 08:00 PM


Same way, you could define things in Interface & later implement things in class using Interface. You could find more than bunch of articles in Codeproject on this topic.


Well, in client-server architecture, an Interface is an contract (i.e an Agreement) between client and server which is implemented on server side and tells the client that what it contains. The examples can be RMI.

One interface can be implemented by more than one classes, that's why you can have multiple kind of instance of that interface.

For example, in .NET object is base class of all of the other classes, even user-defined as well.
This object class implement the interface that has these 4 methods like Equals(), ToString(), GetType() and GetHashCode(). You can find more info here[^].

Let's talk about ToString(). You may find this method each and every damn objects in your application. For example, you can get the String format of int, float, double and/or user defined objects. But the question is how to distinguish which ToString() works for int, which for double and which for float?

So the answer is these wrapper i.e Int, Double, Float etc class has the implement of the object interface and each may have the different implement for ToString().

In this kind of situation you need an interface. Let's say in you application, 5 classes has almost same methods but works differently so you can create one interface, implement by these 5 classes and can use it.

Some examples,
http://msdn.microsoft.com/en-us/library/87d83y5b.aspx[^]

[^]
http://www.onlinebuff.com/article_implementing-interface-in-c-with-an-example_18.html[^]
http://www.c-sharpcorner.com/UploadFile/sekarbalag/interface-best-example-in-csharp/[^]
http://www.c-sharpcorner.com/UploadFile/sekarbalag/interface-best-example-in-csharp/[^]

Hope this would help you.

-KR


这篇关于c#中的实时示例界面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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