Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>No. I consider it visual noise. I think the this variable is a crutch to bad naming styles. Within my type I should be able to manage the naming of the fields, properties and methods.</p> <p>There is absolutely no good reason to name your backing field "myfield", the parameter to the constructor as "myField" and the property to be "myField".</p> <pre><code> public class TestClass { private string myField; public TestClass(string myField) { this.myField = myField; } public string MyField {get { return myField;} set {myField = value}} } </code></pre> <p>Personally, I always add a prefix of _ to all my private backing fields.</p> <pre><code> public class TestClass { private string _myField; public TestClass(string myField) { _myField = myField; } public string MyField {get { return _myField;} set {_myField = value}} } </code></pre> <p>and now with automatic properties in C# </p> <pre><code> public class TestClass { private string MyField {get; set;} public TestClass(string myField) { MyField = myField; } } </code></pre> <p>Other than the above maybe the only other time you type this. is because you want to see the intellisense for your current type. If you need to do this then I submit that your type is too big and probably not following the <a href="http://en.wikipedia.org/wiki/Single_responsibility_principle" rel="noreferrer">Single Responsibility Principle</a>. And lets say you are. Why keep the this. around after you actually make the call. Refactor it out.</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