2
I have a ListBox
that contains an undetermined value of values and I want to play those values to a List<>
and from what I’ve researched, I’ve made it this far:
var todosValores = lstRoll.Items.OfType<object>().Select(x => x.ToString()).ToList();
List<double> listaDeNums = todosValores.Select(s => double.Parse(s)).ToList();
var lista = new List<double>();
lista.Add(somaLinha1);
lista.Add(Math.Round((somaLinha1 + valorTamanhoIntervalo), 2));
The above code plays the values of the ListBox
for a List<>
and then throw it to another List<>
converting to double
values. It turns out that now I have another List
other than those containing decimal numbers.
Supposing that my listaDeNums
now load the values { 1,2,3,...,9,10 }
and my another list (variable lista
in the code) load the values { 2.86 , 5.65 }
.
These two values need to be treated as the beginning and end of an interval that will be intersected in the listaDeNums
and a variable is incremented at each number that is part of the intersection.
In this specific case exemplified by me above my variable incremented at the end, should give 3 because between 2.86 and 5.65 on a list of 1 to 10 there are 3 numbers.
Complicated understand what you need to do? Have some minimal example to ask your question?
– novic
Exactly what Ramaral posted, his second code block almost met me xD
– Igor Henriques