com库函数在C# 中的声明为
bool SelectShapes( int i, ref object result )按照其说明,最后一个参数result为一个整形数组但是当我调用这个函数的时候:
int i;
int aiResult[] = null;
SelectShapes(i, ref (object)aiResult);
这样的语句后,编译老是不过,提示出错信息:错误1: ref 或 out 参数必须是可以赋值的变量。请问该如何通过编译?怎样给形参为ref object result 这样的传递实参呢?谢谢!

解决方案 »

  1.   

    object resultObj = aiResult;
    SelectShapes(i, ref resultObj);
      

  2.   


    int i;
    //int aiResult[] = null;
    int[] aiResult = new int[0]; //必须先初始化,数组长度看实际需要,如果在Com里面有定义,0就可以了。
    SelectShapes(i, ref (object)aiResult);
      

  3.   

    ref 要传递的变量, 得先初始化