So basicly what i do is grabbing an object from my class using this code:
Expand|Select|Wrap|Line Numbers
- public partial class FrmPartialMain : Form
- {
- RsiOPCAuto.OPCServer oOpcServer;
- public FrmPartialMain()
- {
- InitializeComponent();
- object RsiOPCAuto;
- object oOPCList;
- oOpcServer = new RsiOPCAuto.OPCServer();
- oOPCList = oOpcServer.GetOPCServers();
Now I want to put these four strings into a combo box. I do this with a simple for loop:
Expand|Select|Wrap|Line Numbers
- for (int i = 0; i <= oOPCList.Length; i++)
- {
- cboServer.Items.Add(oOPCList[i]);
- }
.Length
Error 1 'object' does not contain a definition for 'Length' and no extension method 'Length' accepting a first argument of type 'object' could be found (are you missing a using directive or an assembly reference?)
oOPCList[i]
Error 2 Cannot apply indexing with [] to an expression of type 'object'
I bet it's just the simplest thing but I just can't see it, help is very much appreciated and if there's anything else you need to know be sure to ask :-)
PS. It might be worth mentioning that I have tried some different ways to convert the object to a string array but I continuously get an error telling me that I can not convert system.string[*] to system.string[], which I guess is pretty obvious if it means what I think it means.
This is the VB.NET code that I am converting:
Expand|Select|Wrap|Line Numbers
- Friend Class frmPartialMain
- Inherits System.Windows.Forms.Form
- Dim oOpcServer As RsiOPCAuto.OPCServer
- Private Sub frmPartialMain_Load(ByVal eventSender As System.Object, ByVal eventArgs As System.EventArgs) Handles MyBase.Load
- Dim RsiOPCAuto As Object
- Dim oOPCList() As Object
- Dim i As Integer
- oOpcServer = New RsiOPCAuto.OPCServer
- oOPCList = oOpcServer.GetOPCServers
- For i = LBound(oOPCList) To UBound(oOPCList)
- cboServer.Items.Add(oOPCList(i))
- Next i