我正在将一个 VB.NET 项目转换为 C#,但我陷入了这个 if 循环,有人可以帮我转换它吗?我假设我需要为此使用 GetType() 方法,但我不确定如何。
循环:
Private Sub oOpcGroup_DataChange(ByVal TransactionID As Integer, ByVal NumItems As Integer, ByRef ClientHandles() As Integer, ByRef ItemValues() As Object, ByRef Qualities() As Integer, ByRef TimeStamps() As Date)
Dim i As Integer
For i = 1 To NumItems
If VarType(ItemValues(i)) And Not VariantType.Array Then
txtSubValue.Text = ItemValues(i)
Else
MsgBox("Data type return error, returned array, expected single item", MsgBoxStyle.Critical, "Data Change Error")
Exit Sub
End If
Next i
Exit Sub
End Sub
这是我到目前为止所拥有的:
void oOpcGroup_DataChange(int TransactionID, int NumItems, ref Array ClientHandles, ref Array ItemValues, ref Array Qualities, ref Array TimeStamps) //Events OPCGroup
{
for (int i = 0; i < NumItems; i++)
{
if(){
}
else
{
MessageBox.Show("Expected single item.", "Data type return error.", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
}
}
}