Return the value of this variable. The simplest application is division. For example, you need a division method to obtain the remainder and quotient at the same time. However, a normal method can only obtain one return value, in this case, you can use the Out parameter to return another value.
When you want the method to return multiple values, it is very useful to declare the out method.
You can still return a value using the out parameter. A method can have more than one out parameter.
To use the out parameter, you must use the parameter as the out parameter to pass it to the method explicitly. The value of the out parameter is not passed to the out parameter.
You do not need to initialize the variable passed as the out parameter. However, the out parameter must be assigned a value before the method is returned.
The property is not a variable and cannot be passed as an out parameter.
Example
// Obtain the returned value
Private string sendMsg (string SendMessageResult, out int FailCount, out int SessCount, out int AllCount, out string sRe)
{
String sStr = "";
String Result = "";
Int dtCount = dtTemp. Rows. Count;
Int dtFailCount = dtCount;
Int dtSessCount = 0;
SStr = SendMessageResult. Substring (0, 1 );
If (sStr = "0 ")
{
DtFailCount = Convert. ToInt32 (SendMessageResult. Substring (2 ));
DtSessCount = dtCount-dtFailCount;
Result = "The message is sent successfully." + dtSessCount. ToString () + ", failed" + dtFailCount. ToString () + "message ";
}
FailCount = dtFailCount;
SessCount = dtSessCount;
AllCount = dtCount;
SRe = sStr;
Return Result;
}
// Call
Private void btnSend_Click (object sender, EventArgs e)
{
Int FailCount;
Int SessCount;
Int AllCount;
String sRe;
String sSendMsg = sendMsg (e. Result, out FailCount, out SessCount, out AllCount, out sRe );
}
From SYZ_YUMEIZHOU_YY