Lars Persson

Lars Persson

  • NA
  • 110
  • 0

Copy Object

Apr 11 2012 12:33 PM
I have List-control of objects.

I want find a certain object and save it away for later use.

To do this, I used a foreach-loop and tried to copy the object I found into a new object-variable.

Something like:

Book temporary = null; //Reference to Book-object

foreach (Book B in BookList)
 if (txtBox1.Text.Equals(B.ID.ToString()))
 temporary = B;

But that doesn´t seem to work.

How can I do this?

Answers (5)