Hello, sounds easy, but can't make it work.
I need a list, which allows duplicates but never one by one.
I have a variable, which value changes constantly. The Timer runs to retrieve its value every second to add it to list.
It happens that the variable doesn't change its value for time longer than one second and there appear two or more same values in a row.
I wrote it like this, to add the value only, if it differs from the last one:
But it keeps adding all of the values.
I'm not sure, if the code is not correct or is it the variable contents changing too fast.
I need a list, which allows duplicates but never one by one.
I have a variable, which value changes constantly. The Timer runs to retrieve its value every second to add it to list.
It happens that the variable doesn't change its value for time longer than one second and there appear two or more same values in a row.
I wrote it like this, to add the value only, if it differs from the last one:
C#:
if (myVariable != myList[myList.Count-1])
myList.Add(myVariable);
But it keeps adding all of the values.
I'm not sure, if the code is not correct or is it the variable contents changing too fast.