Functions also refer to "methods".
static <returnType> <FunctionName>() => <returnValue>; // expression-bodied functions
1 static <returnType> <FunctionName>(<p1Type> <p1Name>, ..., params <type> [] <name>) 2 { 3 4 ... 5 6 return <returnValue>; 7 8 } 9 10 /* the same as fellowing: 11 <FunctionName>(<p1>, ..., <val1>, <val2>, ...)<val1>, <val2>, 12 and so on are values of type <type>, which are used to initialize the <name>array 13 */
in | specifies that this parameter is passed by reference but is only read by the called method |
ref | specifies that this parameter is passed by reference and may be read or written by the called method(must be signed) |
out | specifies that this parameter is passed by reference and is written by the called method (created by called function, treated as an unsigned parameter) |
Variables like strings and arrays are reference types and arrays can be returned with the ref keyword without a parameter declaration.
It‘s designed for returning multiple values from the functions and most used when a program does not need a struct or more complicated implementations.
1 //define a delegate 2 delegate <a define of function>; // now we have the delegate‘s name : <delegateName> 3 //use a delegate 4 <delegateName> <delegateVariableName>; 5 <delegateVariableName> = <FunctionName>; // this function is of the delegate‘s type 6 //now this <delegateVariableName> can be used as a "function" of its type
原文:https://www.cnblogs.com/daizhuo/p/12495626.html