Everything that is passed is a value in the truest sense. However that value is (most) often a reference to the object rather than the 'value' itself.
The only way to do what the op wants is to create a new object (therefore a new reference) and copy the values the object holds. Where the object's values are also references, new copies of those also need to be created. This needs to be done recursively until all object references have been recreated.
This is known as deep cloning and, as you can see, can be quite an involved and complex task which is why there is no built in Clone method in the framework. The closest we have is ICloneable which has (of course as it's an interface) to be implemented by the creator of the class.
Assume I write a class called Customer. On it are CustomerKey and CustomerName properties. You set the key to the customer's PK and call the SaveChanges method.
The SaveChanges method first calls a private bool method called Validate. If the CustomerName property is not completed, how would you deal with it? Throw an exception? Maybe set an ErrorMessage property?
Bear in mind that this class may never actually be bound to any UI. It may only ever be called from another non-visual class.
According to the example on MSDN[^], you'd need to re-assign the bindinsource to the datagridview;
// Filter the items to show contacts who are owners.
BindingSource1.Filter = "LASTNAME='Owner'";
// Sort the items on the company name in descending order.
BindingSource1.Sort = "LASTNAME ASC";
// Set the data source for dataGridView1 to BindingSource1.
dataGridView1.DataSource = BindingSource1;
I'm needing to pull a CLOB field off of an Oracle table. It just so happens that the character string that was input into that CLOB field conforms to an XML Schema, with a few character replacement tweaks that I have to scrub. less than signs have been replaced with amp lt; and greater than signs have been replaced with amp gt;
I mention that because it throws a significant wrinkle into the processing that I have to do. I have to pull a CLOB out of a DataReader's stream, scrub the string, and then dump the string back into a (MemoryStream???) to pass into the XML DOM objects. I have no idea if this is even close to what I need to be doing, as I have very little experience working directly with Streams in this way.
Can someone tell me how they would go about pulling the string data out of the DataReader stream and passing it into an XMLTextReader as a separate stream for parsing?