Apparently, I am not as clear as I thought I was on passing by reference.

In C# I tried to pass a list to a function by ref and it gives some obscure error at run time, but compiled fine.

In the function, I want the original list modified which is I am trying to pass by ref.

I then recursively call the function inside itself with the modified list.

Apparently I don't need to pass by ref, the original list gets modified without it.

I rarely use pass by ref, so I haven't dove into it much. I mean I know what it does, it passes the memory pointer which I figured if I want original list modified, i needed to do, but apparently not. I am not sure if it needs dereferencing or how it works with C#. Guess it's back to school.

Add Comment