Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/278.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
c#无法强制转换类型为'的对象;system.int16[*]和#x27;输入';system.Int16[]和#x27;_C#_Opc - Fatal编程技术网

c#无法强制转换类型为'的对象;system.int16[*]和#x27;输入';system.Int16[]和#x27;

c#无法强制转换类型为'的对象;system.int16[*]和#x27;输入';system.Int16[]和#x27;,c#,opc,C#,Opc,我正在从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

我正在从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;

错误
;应为

系统。int16[*]
是多维数组,而不是一维数组

Array array = (Array)qualities;
int dimensions = array.Rank;
如果
dimensions
为2,则它是
int[,]
。如果是3,则为
int[,]
,依此类推


有关使用
foreach
迭代数组的信息,请参见
系统的示例。int16[*]
是多维数组,而不是一维数组

Array array = (Array)qualities;
int dimensions = array.Rank;
如果
dimensions
为2,则它是
int[,]
。如果是3,则为
int[,]
,依此类推


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

您将强制转换为字符串,然后是
Int16[]
,然后将该值分配给字符串???
((Int16[])。ToString()
也会给出相同的错误@CarbineCoder,
dynamic
库不存在您正在强制转换为字符串,然后是
Int16[]
然后将该值分配给字符串???
((Int16[])。ToString()
也会给出相同的错误@卡宾编码器,
动态
库不存在