Definition of a method signature?

前端 未结 7 1921
萌比男神i
萌比男神i 2020-12-08 10:32

What is the correct definition of a method signature (or a signature of a method)?

On google, I find various definitions:

It is the combinatio

7条回答
  •  死守一世寂寞
    2020-12-08 11:14

    Method signature is the set of attributes of a method that a compiler can use to identify the method.

    The attrbutes are: Method name, number of parameters, parameter type and order of parameters.

    Example of diferent method signatures:

    Foo()
    Foo(int)
    Foo(String)
    Foo(int, string)
    Foo(string, int)
    

    All of these methos are diferent, and when you call them in code the compiler can infer which method are you intent to execute using the method signature.

    Don't forget the scope of the methods in modular programming...

提交回复
热议问题