Method Signature in C#

前端 未结 7 777
误落风尘
误落风尘 2020-11-27 13:36

What is the Method Signature in the following

int DoSomething(int a, int b);

Return type is a part of signature or not???

7条回答
  •  难免孤独
    2020-11-27 13:47

    From MSDN:

    The signature of a method consists of the name of the method and the type and kind (value, reference, or output) of each of its formal parameters, considered in the order left to right. The signature of a method specifically does not include the return type

    Edit: That is from old documentation. It seems the definition of 'signature' has changed since then. Now a method has two different signatures, one for the purpose of overloading and one for the purposes of determining delegate compatibility. See keyboardP's answer below for more details.

提交回复
热议问题