I am having a problem trying to cast an object to an Array. I am trying to extract data from a log file and am using a library that came with another application. There is no documentation so I am trying to figure out how to extract the data. I have got it to the point where I can create an object using their library file and I can trace through using the debug I can see the data. I am just having a problem trying to cast it into a string array to use. I am not sure of the original data type because I do not have the documentation. I have tried to cast it in a few different ways with no success.
Any help is appreciated, thanks
Peter

PeterPosted Feb 12, 2010, 12:17 PM
Peter
obj2 = test.GetFromTo("Devices.Logical.SOURCES.Si2H6_2.Current Value", null, null, null);
Array arrayData = (Array)obj2;
objTime = arrayData.GetValue(0);//Time
objData = arrayData.GetValue(1);//values
Array arrayValue = (Array)objData;
Array arrayTime = (Array)objTime;
String TempValue = "";
String TempTime = "";
for (int i = 0; i < arrayValue.Length; i++)
{
objValue = arrayValue.GetValue(i);
objTime = arrayTime.GetValue(i);
TempValue = TempValue + Environment.NewLine + objValue.ToString();
TempTime = TempTime + Environment.NewLine + objTime.ToString();
textBox2.Text = i.ToString();
}
textBox1.Text = TempValue;
textBox3.Text = TempTime;
Sam HobbsPosted Feb 12, 2010, 12:11 PM
So I think you need to write code that does the conversion. You need to write a loop (using foreach or for or something like that) to get each item in the array and then creates a new array with each item converted.