什么是超载函数的用途。 [英] what is the use of over loaded functions.

查看:154
本文介绍了什么是超载函数的用途。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

而不是使用相同的名称我可以使用不同的名称,

是否有任何特定的purpous来定义c#
中的多态

重载函数br />

Instead of using same name i can use different name,
is there any specific purpous is there to define the polymorphic
overloaded functions in c#

推荐答案

< ve ******************** @ gmail.comwrote in message

新闻:11 ********************** @ i38g2000prf.googlegr oups.com ......
<ve********************@gmail.comwrote in message
news:11**********************@i38g2000prf.googlegr oups.com...

我可以使用不同的名称,而不是使用相同的名称,
Instead of using same name i can use different name,



True,但那时它的功能不同...... :-)

True, but then it''s not the same function...:-)


是否有任何特定的purpous来定义c#
is there any specific purpous is there to define the polymorphic
overloaded functions in c#

中的多态

重载函数

它允许您定义不同的版本。具有相同功能的

不同的签名 - 其他语言使用可选的

参数做了类似的事情,但C#没有,感谢上帝!
http://www.csharpfriends.com/Article .. 。?articleID = 105

-

Mark Rae

ASP.NET MVP
http://www.markrae.net

It allows you to define different "versions" of the same function with
different signatures - other languages did something similar with optional
parameters, but C# doesn''t, thank God!

http://www.csharpfriends.com/Article...?articleID=105
--
Mark Rae
ASP.NET MVP
http://www.markrae.net


7月30日下午12:53,veebhudhi.chandramo ... @ gmail.com写道:
On Jul 30, 12:53 pm, veebhudhi.chandramo...@gmail.com wrote:

我可以使用不同的名字而不是使用相同的名字,

是否有任何特定的purpous来定义多态的

重载函数在c#
Instead of using same name i can use different name,
is there any specific purpous is there to define the polymorphic
overloaded functions in c#



对于构造函数,你不能改名字开头。

对于其他一切 - 不用创建就更方便了br />
许多不同的方法名称。


看看Console.WriteLine的重载,例如 - 你会不会想要
真的想要那个许多不同的方法名称?


Jon

For constructors, you can''t change the name to start with.
For everything else - it''s just more convenient not to have to create
lots of different method names.

Look at the overloads for Console.WriteLine, for example - would you
really want that many different method names?

Jon


重载的一个用途是提供默认参数值。 />

考虑一个函数,它带有三个参数,一个参数是

,对于90%的调用都是一样的。

你可以重载那个带有两个参数的函数和

将调用委托给你原来的函数提供第三个价值

你自己。


我的2c。

ve ***** ***************@gmail.com 写道:
One use of overloaded is to provide default parameter values.

Consider a function that takes three parameters with one parameter being
the same for 90% of the calls.
You could overload that function with one that takes two parameters and
delegate the call to your original function providing the third value
yourself.

My 2c.

ve********************@gmail.com wrote:

而不是使用相同的名称我可以使用不同的名称,

是否有任何特定的紫色来定义多态的

重载函数在c#
Instead of using same name i can use different name,
is there any specific purpous is there to define the polymorphic
overloaded functions in c#



-

Hitesh Ashar

hitesh(at)asharism(dot)com

--
Hitesh Ashar
hitesh (at) asharism (dot) com


这篇关于什么是超载函数的用途。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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