Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Let's go through each line:</p> <pre><code>myObject bob; // Creates a variable of type myObject, but it doesn't point anywhere bob = new myObject(); // bob now points to a newly created myObject instance myObject joe; // Creates a variable of type myObject, but it doesn't point anywhere joe = bob; // joe now refers to the same object as bob </code></pre> <p>An important thing to keep in mind is that the last line copies over the value of the reference itself. Such as if <code>bob</code> points to address 1000, <code>joe</code> will also point there. Thus, if you <em>change</em> any data at this address, both <code>joe</code> and <code>bob</code> will point to that same data.</p> <p>However, you're welcome to set <code>joe</code> to <em>point</em> somewhere else and it will not affect <code>bob</code>. In other words:</p> <pre><code>joe = null; // This will not null out bob </code></pre> <p>If you wanted to create a <em>brand new</em> instance of <code>myObject</code>, you'd have to do this:</p> <pre><code>joe = new myObject(); // This will also not affect bob </code></pre> <p>Now, if you're trying to create a new instance of <code>myObject</code> in memory and <em>copy over</em> all of the properties of an existing instance, you'd have to do this yourself:</p> <pre><code>joe = new myObject(); joe.X = bob.X; // Assuming X is not a reference itself joe.Y = bob.Y; // ...or you'd have to do this recursively </code></pre> <p>.NET does not provide a way to do this copying for you. One common pattern is to make a constructor for <code>myObject()</code> that takes an instance of <code>myObject</code> and copies all its properties:</p> <pre><code>joe = new myObject(bob); </code></pre>
    singulars
    1. This table or related slice is empty.
    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. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    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