Each part of my array has 6 bits of data shown here
83 0 0 -1 0 50
83 0 0 -1 0 50
85 0 0 -1 0 50
87 0 0 -1 0 50
89 0 0 -1 0 50
i need to parse each one into a new array so i can then go on to find averages and more. the first colum is heartrate the second is speed and is to the power of 10 so will need to be in some sort of decimal i was thinking floating point. cheers for any help
this is what ive got so far
int[] hrDataList = new int[5];
开发者_Go百科 string[] seperator = { "\t" };
for (int i = 0; i < hrDataList.Length; i++)
{
string[] temp = hrDataList[i].ToString().Split(seperator, StringSplitOptions.None);
heartrate[i] = int.Parse(temp[0]);
speed[i] = int.Parse(temp[1]);
cad[i] = int.Parse(temp[2]);
alt[i] = int.Parse(temp[3]);
pwr[i] = int.Parse(temp[4]);
pwrbal[i] = int.Parse(temp[5]);
}
Try something like this:
int[] thearray = new int[5];
int[][] thenewarray = new int[5][];
string[] seperator = { "\t" };
for (int i = 0; i < thearray.Length; i++)
{
string[] temp = thearray[i].ToString().Split(seperator, StringSplitOptions.None);
int[] toadd = new int[temp.Length];
thenewarray[i] = new int[temp.Length];
for (int j = 0; j < temp.Length; j++)
{
thenewarray[i][j] = int.Parse(temp[j]);
}
}
Tested and works.
精彩评论