Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>So basically, your question is Properties vs Public Variables. When to use what?</p> <p>Read <a href="http://www.codinghorror.com/blog/2006/08/properties-vs-public-variables.html" rel="nofollow">this Post</a>, including the comments. </p> <p>A quick summary of entire discussion:</p> <ul> <li>Reflection works differently on variables vs. properties, so if you rely on reflection,<br> it's easier to use all properties.</li> <li>You can't databind against a variable.</li> <li>Changing a variable to a property is a breaking change.</li> </ul> <p>Trivial property implementation of exposing a data member is a lot of code for no or little gain and only rational reasons can be:</p> <ul> <li><p>To provide read-only access to a member var that cannot be declared const for some reason</p></li> <li><p>If you're writing a component that is meant for use by some 3rd parties and there exists any chance that the component will have to be replaced without requiring a rebuild by those users (changing a public member variable to a property breaks the interface, so a rebuild is needed).</p></li> </ul> <p>Also, wrap public fields in properties, for two reasons - one is that you can't change it later without breaking binary compatibility. Two is that you can't bind to fields.</p> <pre><code>Reflection code against fields looks very different from reflection code against properties (FieldInfo vs. PropertyInfo for starters). So even if you can recompile against the new binary, if you use reflection on that field you're hosed. </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.
    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