|
-
Dec 20th, 2005, 05:01 AM
#1
Convert VB.Net to C#
Hello
This is a bit of a big ask, but I have taken the leap to try and create an Application, which I have working in VB.NET 2005, to C# 2005, and to be honest I am struggling!!!
Can anyone suggest an equivalent way of writing the following method in C#
VB Code:
Private Sub ConnectedGroup_DataChange(ByVal TransactionID As Integer, ByVal NumItems As Integer, ByRef ClientHandles As System.Array, ByRef ItemValues As System.Array, ByRef Qualities As System.Array, ByRef TimeStamps As System.Array) Handles ConnectedGroup.DataChange
' We don't have error handling here since this is an event called from the OPC interface
Try
Dim i As Short
For i = 1 To NumItems
' Use the 'Clienthandles' array returned by the server to pull out the
' index number of the control to update and load the value.
If IsArray(ItemValues(i)) Then
Dim ItsAnArray As Array
Dim x As Integer
Dim Suffix As String
ItsAnArray = ItemValues(i)
' Store the size of array for use by sync write
OPCItemIsArray(ClientHandles(i)) = ItsAnArray.GetUpperBound(0) + 1
OPCItemValue(ClientHandles(i)).Text = ""
For x = ItsAnArray.GetLowerBound(0) To ItsAnArray.GetUpperBound(0)
If x = ItsAnArray.GetUpperBound(0) Then
Suffix = ""
Else
Suffix = ", "
End If
OPCItemValue(ClientHandles(i)).Text = _
OPCItemValue(ClientHandles(i)).Text & ItsAnArray(x) & Suffix
Next x
Else
OPCItemValue(ClientHandles(i)).Text = ItemValues(i)
End If
Next i
Catch ex As Exception
' Error handling
MessageBox.Show("OPC DataChange failed with exception: " + ex.Message, "SimpleOPCInterface Exception", MessageBoxButtons.OK)
End Try
End Sub
I have tried a number of different things, but cannot find an "equivalent" of the VB IsArray method. And also when I pass the Array into the method ByRef I do not seem to be able to access the members of that array in the way that I would expect i.e.
ItemValues[i] = something
I get the error:
Cannot apply indexing with [] to an expression of type 'System.Array'
Any ideas?!?!?
Thank you for your help!!
Gary
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|