'C# show if numbers in listbox getting bigger or smaller
I have a listbox that numbers are added each 10 seconds. Numbers such as ( -5, -4, -3, -2, 0, 1, 3, 5, 6, 3, 2)
New numbers added after the number 2. I want to show that if the numbers are increasing from -5 to 2, then the outcome would be positive. However, lets say if the numbers are decreasing, then it would have a outcome of negative. In the parenthesis you can see the numbers are increasing from -5 to 2, so the outcome should be positive. How do I express that programmatically.
foreach(decimal item in listBox1.Items)
{
if (listBox1.Items.Count -1 > listBox1.Items.Count -2) // this line is where i am confused on how to do. it has to consider all numbers in listbox and see if the direction of the numbers is going positive or negative.
{
MessageBox.Show("numbers are increasing OUTPUT: POSITIVE");
}
}
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
