Click here to Skip to main content
15,909,629 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hiii everybody,i'm beginner

please what is asignature in object orinted programming in such as methods
Posted
Comments
VJ Reddy 31-May-12 6:29am    
Thank you, mhassan083, for accepting the solution :)

Do you really need I search Wikipedia[^] for you?
 
Share this answer
 
The name of the method, number and type of the parameters constitute the Signature of the method.

The return type of the method is not part of the Signature of the method.

For method overloading the signature should be different. The order and type of the parameters is important whereas the name of the parameter is not significant in the sense that when the names of the parameter is different or same in different overloads of a method it does not make difference.

examples

C#
private void method(string param1, int param2){

}

//Not valid
private int method(string param1, int param2){

}

private void method(string param3){

}
private void method(int param1, string param2){

}
 
Share this answer
 
v2
Comments
Maciej Los 31-May-12 9:34am    
Good answer, my 5!
VJ Reddy 31-May-12 10:37am    
Thank you, losmac :)
A signature makes a method look unique to the compiler.

The method name and the type and order of parameters all contribute to the uniqueness of signatures.

Methods, constructors, indexers, and operators are characterized by their signatures.

Signatures enable the overloading mechanism of members in classes, structs, and interfaces.

A method signature consists of the name of the method and the type and kind, such as value or reference.
A method signature does not include the return type, nor does it include the params modifier that may be specified for the last parameter.

A constructor signature consists of the type and kind, such as value or reference. A constructor signature does not include the params modifier that may be specified for the last parameter.

An indexer signature consists of the type. An indexer signature does not include the element type.

An operator signature consists of the name of the operator and the type. An operator signature does not include the result type.

Signatures Example class
C#
void MyFunc(); // MyFunc ()

            void MyFunc(int x); // MyFunc (int)

            void MyFunc(ref int x); // MyFunc (ref int)

            void MyFunc(out int x); // MyFunc (out int)

            void MyFunc(int x, int y); // MyFunc (int, int)

            int MyFunc(string s); // MyFunc (string)

            int MyFunc(int x); // MyFunc (int)

            void MyFunc(string[] a); // MyFunc (string[])

            void MyFunc(params string[] a); // MyFunc (string[])



The ref and out parameter modifiers are part of a signature.

MyFunc(int), MyFunc(ref int), and MyFunc(out int) are all unique signatures.

The return type and the params modifier are not part of a signature, and it is not possible to overload based solely on return type or on the inclusion or exclusion of the params modifier.

Notice that there are some errors for the methods that contain duplicate signatures like MyFunc(int) and MyFunc(string[]) whose multiple signatures differ only by return type.
 
Share this answer
 
v2
Comments
VJ Reddy 31-May-12 6:15am    
Good answer. 5!
Prasad_Kulkarni 31-May-12 23:40pm    
Thank you VJ!
Maciej Los 31-May-12 9:34am    
Good work, my 5!
codeBegin 1-Jun-12 8:56am    
Nice explanation +5!

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900