Note that there are some explanatory texts on larger screens.

plurals
  1. POIn C#, how to create an array of data that's updating every 15 seconds
    primarykey
    data
    text
    <p>I'm a programming student that is assigned a project where I have to use a random number representing a user selected unit of measurement and returning the measurement, the converted measurement, and the time collected. </p> <p>I set up a dispatcher timer at an interval of 15 seconds for the timer. So how it works is the program triggers an event every 15 seconds that displays a random number in either a metric or English measurement, then displays the converted value and the time and of course, the timer starts with a start button and displays the data until a stop button is depressed. </p> <p>My question is that I would like to show a limited history of the collected data, but I am having trouble with the array. Each time it changes to a new data, it either writes over the previous data or doesn't add the new data, depending on how I formulate the statement. So when displaying to a label, it only shows one line of the current data, and not showing any other data.</p> <p>For example, the user selects "centimeters" the program determines that it is metric and uses a random number as its value concatenated with the converted value and time value. <br/>15 seconds later the event is triggered and a new random number is displayed for "centimeters". <br/>So after combining the three values (measurement, converted measurement and time) which I'll call dataCollected, I populate the array: </p> <pre><code> string [] dataHistory = new string[10] for (int i = 0; i &lt; dataHistory.Length; i++) { if (dataHistory[i] == null || dataHistory[i] == "") { dataHistory[i] = dataTlt + "\n"; } } foreach (string c in dataHistory) { collectedLbl.Content = c; } </code></pre> <p>Not sure what I'm doing wrong.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload