Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Other framework or libraries, or programming languages, have an object hierarchy where an instance of an object can copy the values of its fields and properties to other objects, from related, but, not exactly the same class, objects. Because, it has specific methods for copying fields or properties.</p> <pre><code>public class classRoot { public string Name { get; set; } public virtual void assignFrom(myRootClass objSource) { if (objSource != null) { this.Name = objSource.Name; } } public virtual void assignTo(ref myRootClass objDest) { if (objDest != null) { objDest.Name = this.Name; } } } public class classFoo: classRoot { public Color Color { get; set; } public override void assignFrom(myRootClass objSource) { updateChanges(); } public override void assignTo(ref myRootClass objDest) { updateChanges(); } } public class classBar: classRoot { public int Age { get; set; } public override void assignFrom(myRootClass objSource) { updateChanges(); } public override void assignTo(ref myRootClass objDest) { updateChanges(); } } public class classDemo { public void anyMethod() { classFoo objFoo = new classFoo("Foo1"); classFoo objBar = new classBar("Bar2"); MessageBox.Show("Name: " + objFoo); objBar.AssignTo(ref objFoo); MessageBox.Show("Name: " + objFoo); } } </code></pre> <p>Don't confuse this concept, with the make a "clone()", or make a "deepCopy()" or make "shallowCopy()", altought in some cases are solved with this function.</p> <p>Those functions help when you want to make a new object with the same class, and you want to copy data from an existing object to another existing object, where the classes are related, but may not be exactly the same thing.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
 

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