使用out 参数必须由接受方为其赋值,即在函数内部必须为他的参数赋值。 原型:int rd_asc(unsigned char* buff) 内部肯定是没有这样做的。所以发生错误你使用ref 代替 out即可例如: using System; class TestOut { static public void FillArray(out int[] myArray) { // Initialize the array: myArray = new int[5] {1, 2, 3, 4, 5}; } static public void Main() { int[] myArray; // Initialization is not required // Pass the array to the callee using out: FillArray(out myArray); // Display the array elements: Console.WriteLine("Array elements are:"); for (int i=0; i < myArray.Length; i++) Console.WriteLine(myArray[i]); } }
原型:int rd_asc(unsigned char* buff) 内部肯定是没有这样做的。所以发生错误你使用ref 代替 out即可例如:
using System;
class TestOut
{
static public void FillArray(out int[] myArray)
{
// Initialize the array:
myArray = new int[5] {1, 2, 3, 4, 5};
} static public void Main()
{
int[] myArray; // Initialization is not required // Pass the array to the callee using out:
FillArray(out myArray); // Display the array elements:
Console.WriteLine("Array elements are:");
for (int i=0; i < myArray.Length; i++)
Console.WriteLine(myArray[i]);
}
}
例如:
void GetBack(out boolean isGetBack)
{
isGetBack=true;
}