c# 无法将类型 'system.int16[*]' 的对象转换为类型 'system.Int16[]'

c# unable to cast object of type 'system.int16[*]' to type 'system.Int16[]'

我正在读取 plc 标签的值

public void synch_read() //reads device
{
    Array values;
    Array errors;
    object qualities = new object(); //opc server will store the quality of the item 
    object timestamps = new object(); //store the timestamp of the read

    //read directly from device
    oGroup.SyncRead((short)OPCAutomation.OPCDataSource.OPCDevice, 2, ref handles, out values, out errors, out qualities, out timestamps);

     String abcd = (Int16[])qualities.ToString();
}

在这一行

String abcd = ((Int16[])qualities).ToString();

我遇到错误

unable to cast object of type 'system.int16[*]' to type 'system.Int16[]'

如何解决这个错误?

编辑

我试过了

Int16[] abcd = (Int16[2])qualities;

错误; expected

system.int16[*]是多维数组,不是一维数组。

Array array = (Array)qualities;
int dimensions = array.Rank;

如果dimensions是2,那么就是int[,]。如果是 3 就是 int[,,] 等等。

要使用 foreach 迭代数组,请参见