方法签名 [英] Method Signature

查看:102
本文介绍了方法签名的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

方法签名也包括方法的返回类型吗?

这是非常矛盾的,因为在MSDN中,它写为不包含方法的返回类型,但是在某些书籍(包括Wrox出版物)中,则写为包括该方法.

有人可以指导我吗?

Does method signature include return type of method also??

This is very conflicting because in MSDN it is written that it doesn''t include return type of the methods, but in some books(including Wrox publication) it is written that it includes it.

Can anybody please guide me about this?

推荐答案

写道:​​

方法签名还包括方法的返回类型?

Does Method signature includes return type of method also??



方法签名永远不会包含方法的返回类型.方法签名仅包括方法参数.

因此,以下两种方法相同.你不能超载:

void StoreAccount(字符串userName,字符串地址);
bool StoreAccount(字符串用户名,字符串地址);

由于方法参数不同,以下两种方法不同:

void StoreAccount(string userName);
void StoreAccount(字符串userName,字符串地址);

希望能解决您的问题.



Method signature never includes return type of method. Method signature only includes the method parameters.

Hence, the following two methods are same & you can''t overload:

void StoreAccount(string userName, string address);
bool StoreAccount(string userName, string address);

The following two methods are different as the method parameters are different:

void StoreAccount(string userName);
void StoreAccount(string userName, string address);

Hope, this resolved your problem.


在这里看看-
Take a look here - http://stackoverflow.com/questions/290038/is-the-return-type-part-of-the-function-signature[^]. This documentation given there is for C++.

So, I guess return type in the method signature could depend on the language.

How does Java work?


这篇关于方法签名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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