Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 321
  • Last Modified:

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?
0
ocaccy
Asked:
ocaccy
  • 4
  • 2
1 Solution
 
käµfm³d 👽Commented:
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

0
 
ocaccyAuthor Commented:
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.
0
 
käµfm³d 👽Commented:
Arrays don't really have "rows," at least not the single-dimension arrays. Are you saying you have a multi-dimensional array?

e.g.

string[,] myArray1 = new string[12, 128];

// or

string[][] myArray2 = new string[12][];

Open in new window

0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ocaccyAuthor Commented:
I´m using C#!


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

Open in new window

0
 
ocaccyAuthor Commented:
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

0
 
ocaccyAuthor Commented:
Thanks, you helped me understand the problem.
This helped me to solve.

Best Regards,
ocaccy
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now