How to use List in C#
how to avoid overwriting value when using a list?
Here is my Problem: i wanted to save to a list the last value i got to use to calculate.... example First time you go to the function and get the resulted value, store that value and the next time you go back you can access that value and then take that value-current value and equal to the Value wanted.VALUE [A]
VALUE [B]VALUE [A] - VALUE[B]= VALUE[C]
HOWEVER whats happening is that V开发者_如何学PythonALUE [A] Always is being replaced......
ListOfLastValue.Add(ResponseTimesOfApp);
// Loop through List with foreach
foreach (string LatestResponseTimes in ListOfLastValue)
{
Console.WriteLine(LatestResponseTimes);
}
// Loop through List with for
for (int i = 0; i < ListOfLastValue.Count; i++)
{
Console.WriteLine(ListOfLastValue[i]);
}
use SortedList mylist = new SortedList()
with sortedlist the information is stored as a key value pair.
and easily retrievable using key as string var = mylist[key];
精彩评论