什么是方法签名? [英] What is a method signature?

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

问题描述

我读了一本书,标题为"Java的对象优先",在第7页中,作者提到方法签名提供了调用该方法所需的信息".作者给出了以下示例:

I read a book titled 'Object First with Java' and in page 7 the author mentioned that the method signature "provides information needed to invoke that method". And the the author gave the following example:

void moveHorizontal(int distance)

但是,今天,当我在Pluralsight上观看有关C#的视频时,作者说方法的返回类型不属于方法签名的一部分".

However, today when I was watching a video about C# on Pluralsight, the author said that "the return type of a method is not part of the method signature".

我现在很困惑,想知道什么是方法签名?

I'm confused now and would like know what is a method signature?

推荐答案

方法签名是方法的一部分,您可以基于该方法重载/覆盖.它包含:

A method-signature is the part of the method based on which you overload / override it. It contains :

  1. 方法名称.
  2. 传递给它的参数.

它不包含:

  1. 范围/访问修饰符
  2. 返回类型.

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

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