开发者

How to use List in C#

开发者 https://www.devze.com 2023-04-11 04:26 出处:网络
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 resu

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];

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号