Recursive insert-method for a linked list
Posted
by
user3726477
on Stack Overflow
See other posts from Stack Overflow
or by user3726477
Published on 2014-06-10T15:21:36Z
Indexed on
2014/06/10
15:24 UTC
Read the original article
Hit count: 171
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);
© Stack Overflow or respective owner