I know this is probably simple, but I cant seem to find the solution in MSDN.
I have a collection of custom objects. The list of these objects is shown in a listbox on my form. I have a copy button that is supposed to create a new object with all the same data as the selected object. The only difference is the Name property changes to "Copy of " + object.Name. Simple enough, except the new object is a reference of the old, so the original object also gets its name changed to "Copy of ..." as well as its data changed whenever the new object is worked with.
heres my copy method:
I have a collection of custom objects. The list of these objects is shown in a listbox on my form. I have a copy button that is supposed to create a new object with all the same data as the selected object. The only difference is the Name property changes to "Copy of " + object.Name. Simple enough, except the new object is a reference of the old, so the original object also gets its name changed to "Copy of ..." as well as its data changed whenever the new object is worked with.
heres my copy method:
Code:
[navy]public void[/navy] CopySurface()
{
[green]//Creates a new surface with settings of selected surface[/green]
Surface newSurface = [navy]new[/navy] SurfaceCollection[intCurrentSurface];
newSurface.Name = "Copy of " + newSurface.Name;
SurfaceCollection.Add(newSurface);
}