RefThe keyword can convert the input parameter to the reference type (int is a value type, but it is converted to the reference type after ref is added, and ref must be added before the parameter is called when the function is called)
OutThe keyword is the same as the ref keyword. However, the ref parameter must be initialized before being passed, but the out parameter must be assigned a value in the function (that is, the passed parameter may not be initialized, however, you must assign values to this parameter)
Eg: If you want to determine whether a character is of the integer type, you can write it like this (by the way, the usage of TryParse ):
Protected string DigResult (string input)
{
// Define an integer variable. You can skip initialization.
Int result;
// Call int. TryParse () to determine whether the input is an integer. If so, assign the input to the result.
// When the function is executed, the result has been assigned a value. Therefore, out does not need to be initialized when the variable is defined.
If (int. TryParse (input, out result ))
{
Return result;
}
Else
{
Return "";
}
}