03-10-2014 07:08 AM
Hello,
I am trying to read out an string array from a MatrikonOPC server, but when I am trying to read out the values the only thing that I get is value System.string[].
The code I am trying to use (C#):
String opcUrl = "opc://localhost/MATRIKON.OPC.Simulation/Bucket Brigade.ArrayOfString";
String[] midString;
string pattern = (":");
datasocket.Connect(opcUrl, AccessMode.ReadWriteAutoUpdate);
midString = datasocket.Data.Value;
string[] substring = Regex.Split(midString, pattern);
With this code I get that it cannot implicit convert an object to string[].
03-12-2014 11:17 AM
I haven't used datasocket previously but the error seems to indicate that the datasocket.Data.Value is returning an Object and not a string[]. You would need to perform casting to a string before using the returned object. Maybe something like this would work
string midString = datasocket.Data.Value as string;
if (!string.IsNullOrEmpty( midString ))
{
.... do something with the string.........
}