Given the following in C#:
public Complex SomeMethodName<ISomething>(int x, int y, ....)
we can describe each part as follows :
public : accessor specifier
Complex : the resut of the function
SomeMethodName : Method Name
<ISomething> : ???
(int x, int y, ....) : parameter list
My question is what is the name for <ISomething>
Part?
PS : I know the name for angle brackets, but what does that part signify? the generiticisim of the method?
Update : for example we would read
public Complex SomeMethodName(int x, int y, ....)
as public method SomeMethodName returning Complex as result and taking parameters int x, int y, ...
Should we read
public Complex SomeMethodName<ISomething>(int x, int y, ....)
as public method SomeMethodName of generic type ISomething returning Complex as result and taking parameters int x, int y, ... ?
My question is what is the name for Part?
is type parameter for generic method.
For example:
static void Swap<T>(ref T lhs, ref T rhs)
{
T temp;
temp = lhs;
lhs = rhs;
rhs = temp;
}
The above defined method is called with replaced with desired type:
public static void TestSwap()
{
int a = 1;
int b = 2;
Swap<int>(ref a, ref b);
System.Console.WriteLine(a + " " + b);
}
So in the above Swap<int>
here we are passing type parameter int
This Link explains about generic methods.
Template type. Template typename. Template parameter. Template argument.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.