I have 2 textboxes that get updated regularly, via serial port each of them displays data on 1 line, I want to get the sum of these values from these textboxes and put the sum into another text box.
Code:
value 1 and 2 are type string
textbox1.text = value1;
textbox2.text = value2;
double value3 = convert.ToDouble(value1) + convert.ToDouble(value2);
textbox3.text = value3.ToString();
Output textbox1:
100, after sometime updates to 200, then 300
Output textbox2:
50, after sometime updates to 100, then 150
What I'm getting, output in textbox3:
150, after some time updates to 300, then 450
The value I should get is
100+200+300+50+100+150
solved my own problem, ill post here in case someone else might be in the same position
used two lists got the sums and added the sums
List<double> totalvalueList = new List<double>();
totalvalueList.Add(Convert.ToDouble(value1));
double totalval = totalvalueList.Sum();