Signatures
18:47Introduction
In this world everything are recognize to their behavior, nature or something, means we can uniquely identify them. So, in OOPS concept "Signature" is same like that. It helps to identify Methods, constructors, indexers etc. A signature makes a method look unique to the C# compiler.
Properties Of Signatures
1. The method name and the type and order of parameters all contribute to the uniqueness of signatures.
2. Signatures enable the overloading mechanism of members in classes, structs, and interfaces.
3. A method signature consists of the name of the method and the type and kind, such as value or reference.
4. An operator signature consists of the name of the operator and the type. An operator signature does not include the result type.
5. A method signature does not include the return type, nor does it include the params modifier that may be specified for the last parameter.
6. 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.
7. An indexer signature consists of the type. An indexer signature does not include the element type.
Signatures Example
void Method(); // Method () void Method(int x); // Method (int) void Method(ref int x); // Method (ref int) void Method(out int x); // Method (out int) void Method(int x, int y); // Method (int, int) int Method(string s); // Method (string) int Method(int x); // Method (int) void Method(string[] a); // Method (string[]) void Method(params string[] a); // Method (string[])
Description
The ref and out parameter modifiers are part of a signature. Method(int), Method(ref int), and Method(out int) are all unique signatures. The return type and the params modifier are not part of a signature. Notice that there are some errors for the methods that contain duplicate signatures like Method(int) and Method(string[]) whose multiple signatures differ only by return type.
Conclusion
Hi guys I try to explain signature hope its helpful.
0 comments