Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is this really a simplification?

Tags:

So I have a pretty simple class with an Id field, and the Id can be set in the constructor.

Typically I will use this to clearly identify the class property as opposed to the method argument. To me this seems clearer.

IDE0003 wants me to remove the this, with the message 'Name can be simplified', is that correct?

This seems less clear to me, and also allows a casing error to easily result in id = id.

enter image description here

like image 212
James Wood Avatar asked Oct 17 '15 13:10

James Wood


1 Answers

This other question has an answer that says you can configure the editor to remove the behavior. Personally I like "this"

Tools > Options > Text Editor > C# > Code Style and check Qualify member access with 'this' 

Visual Studio 2015 - Change Light Bulb, Quick Action settings

like image 111
maddoxej Avatar answered Jan 03 '23 10:01

maddoxej