rlsuth

rlsuth

  • NA
  • 9
  • 0

Noob problem.....

Mar 3 2005 10:29 PM
I'm completely new to C# and OOP in general (yes, I'm a mainframer) so forgive me if this question makes no sense. I've written a program that has an array of objects. I pass this array to a method and immediately create a new instance of the array and copy the passed array into the new instance. I then make changes to the copy and when finished, try to copy the original, passed array back into the new instance. This is where I run into a problem: both versions have been changed, even though I only worked on the copy. I understand that this is probably something to do with the arrays being ref types by default, but how do I create a unique copy? (or am I completely missing the real problem?)

Answers (5)