Note that there are some explanatory texts on larger screens.

plurals
  1. PODuplicating an object in List<T>
    text
    copied!<p>Time for my first question! I want to make it known that I'm quite amateur with programming, and I probably don't fully understand the terms I'm about to use.</p> <p>I'm making a program that takes the results from an Oracle Query and displays them in a DataGridView for manipulation. The data will be used with an imposition software and I need to be able to "split" and "join" rows to make duplicates.</p> <p>The data comes in from my service layer as a generic collection called CheckOrderLine that contains 20+ objects containing all the data pulled.</p> <p>I'm looking for a way to take the current CheckOrderLine from my Binding Source, _bs, and make a new CheckOrderLine with all of the same values. I believe this is known as a deep copy.</p> <p>I've learned that I can use the following code to achieve my goal, but I'm sure there's a better way to do it:</p> <pre><code> CheckOrderLine current = (CheckOrderLine)_bs.Current; CheckOrderLine cloned = new CheckOrderLine(); cloned.OrderNumber = current.OrderNumber; cloned.Qty = current.Qty; </code></pre> <p>and so on.</p> <p><strong>So I guess my question is this:</strong> Is there a way to iterate through the CheckOrderLine and set the values for each property in my new object? Also, is there something horribly wrong with the direction I'm headed? I've seen things around the Web talking about using ICloneable in my CheckOrderLine class, but that's way over my head at this point.</p> <p><strong>EDIT:</strong> Had the wrong VS tag. And I fixed some vocabulary.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload