Link to home
Start Free TrialLog in
Avatar of ocaccy
ocaccyFlag for Japan

asked on

C# - On int myArray[] = new int[320]; filled to the row 129

How to get filled row, add more one, fill the array in empty position, and the other arrays connected to it in the same nember rows?
Avatar of kaufmed
kaufmed
Flag of United States of America image

Filled how? Where does the data come from?

For an array, the indexes start at zero. Row 129 would be index 128 of the array. To put data in that slot, you would simply do:

myArray[128] = 88;

Open in new window

Avatar of ocaccy

ASKER

I know this kaufmed, but the system is get data from serial port and putting in the next row in array.

I am receiving data from serial port.
After the trim (), substring () or split (), we send this data to arrays.

I have an array index to an array for the date and time, and six arrays for each device.
I need the values ¿¿of each device in the correct locations in the arrays.
In the next part of the work, I will use the data from these arrays to the first 8 equations and launch other arrays,
Hence it must come at the right place, not to have problems with the data in front.
ASKER CERTIFIED SOLUTION
Avatar of kaufmed
kaufmed
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ocaccy

ASKER

I´m using C#!


public double[] a_d_index = new double[240];

Open in new window

Avatar of ocaccy

ASKER

Kaufmed, this problem is solved.

I created a variable:

int i_C_AR = Convert.ToInt32(lbl_contador.Text);

every access the serial port 1 increment "i_C_AR ++"

then:

a_i_sagyou0[i_C_AR, 0] = Convert.ToDouble(stringOut.Trim().Substring(4, 5));
......

so far has not problem, if it goes again I ask.

Best Regards,
ocaccy
#region Put data in the ARRAYS a_i_sagyou0 ............................................

                        int i_C_AR = Convert.ToInt32(lbl_contador.Text);
                        if (stringOut.Trim().Substring(4, 5) != "")
                        {
                            a_i_sagyou0[i_C_AR, 0] = Convert.ToDouble(stringOut.Trim().Substring(4, 5));
                        }
                        if (stringOut.Trim().Substring(10, 5) != "")
                        {
                            a_i_sagyou0[i_C_AR, 1] = Convert.ToDouble(stringOut.Trim().Substring(10, 5));
                        }
                        if (stringOut.Trim().Substring(16, 5) != "")
                        {
                            a_i_sagyou0[i_C_AR, 2] = Convert.ToDouble(stringOut.Trim().Substring(16, 5));
                        }
                        
                        #endregion

Open in new window

Avatar of ocaccy

ASKER

Thanks, you helped me understand the problem.
This helped me to solve.

Best Regards,
ocaccy