I need to read data from an array located in another class. I have already read a few threads explaining the same problem, but can't get it to work with my code...
Included example: I need to read the data in the ParticipantX array from Parsedata class to the Form1 class, as shown in my example.
I would be really grateful for any help. Best off all would be if you could help me with the code I need. I just got stuck now. Thanks.
public class Parsedata
{
public void ParsedataMethod()
{
...
//Neccesary data are added to this array
string[,] ParticipantX = new string[40, 4];
In the same namespace I have the Form1 class:
using Crestron.ActiveCNX;
public partial class Form1 : Form
{
ActiveCNX cnx;
cnx = new ActiveCNX();
private void SerialSend_Click(object sender, EventArgs e)
{
int number = 8;
for (int i = 1; i < number; i++)
cnx.SendSerial(i, ParticipantX[i, 1]); //
}
Try this:
public class Parsedata
{
private string[,] m_ParticipantX;
public void ParsedataMethod()
{
...
m_ParticipantX = new string[40, 4];//Neccesary data are added to this array
}
public string[,] ParticipantX
{
get { return m_ParticipantX; }
}
}
using Crestron.ActiveCNX;
public partial class Form1 : Form
{
ActiveCNX cnx;
cnx = new ActiveCNX();
Parsedata data = new Parsedata();
private void SerialSend_Click(object sender, EventArgs e)
{
data.ParseDataMethod();
int number = 8;
for (int i = 1; i < number; i++)
cnx.SendSerial(i, data.ParticipantX[i, 1]); //
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With