Recursive insert-method for a linked list
- by user3726477
I'm learning C# and I've made a recursive insert-method for a linked list:
public static int recursiveInsert(ref int value, ref MyLinkedList list) {
if (list == null)
return new MyLinkedList(value, null);
else {
list.next = recursiveInsert(ref int value, ref list.next);
return list;
}
}
How would you modify this method to make the recursive call look like this:
recursiveInsert(value, ref list.next)
instead of:
list.next = recursiveInsert(ref int value, ref list.next);