title: c# linkedlist how to get the the element that is before the last element
body: <p>i try to implement a redo undo in my windows form application.</p>
  
  <p>i build a linkedlist , every entery of the list is a class that save the state of all the elemnts in the form.</p>
  
  <p>every click on the save button , insert to this list the last state of the form elements.</p>
  
  <p>when the user click on undo button i want to get the entery of the list (one before the last)
  and load it.</p>
  
  <p>i dont know what is the simple way to get this one before elemnts from the linked list ?</p>
  
  <p>my code like look like:</p>
  
  <pre><code> public class SaveState {
  
            public int comboBox1;
            public int comboBox2;
            ..........
            public SaveState() {
             .......
            }
      }
      LinkedList&lt;SaveState&gt; RedoUndo = new LinkedList&lt;SaveState&gt;();
  
      # in save function
      var this_state = new SaveState();           
      this_state = getAllState();
      RedoUndo.AddLast(this_state);
  
      # when click undo
      var cur_state = new SaveState();
      # this lines dont work !!!!!!!!!
      int get = RedoUndo.Count - 1;        
      cur_state = RedoUndo.Find(get);
      setAllState(cur_state);
  </code></pre>