Is it possible to take an element from the previous position to the current position using the foreach
loop?
For example, whenever I need to pick up an element earlier than the current loop position, I use the for
loop as follows:
List<int> ListaDados = new List<int>();
ListaDados.Add(1); ListaDados.Add(2); ListaDados.Add(3); ListaDados.Add(5);
for(int i=1; i < ListaDados.Count; i++) {
var elementoAtual = ListaDados[i];
var elementoAnterior = ListaDados[i-1];
}