I\'m trying to write a simple method to count all the nodes in the linked list. I know there are 7 items in the linked list, but it is returning just 6 of them.
Her
You should check for null first. If not 0, then set 'counter = 1' before you loop through it.
if (_first == null) return 0; int count = 1; for (ListNode n = _first; n.Next != null; n = n.Next) { count++; } return count;