-1

I'm looking at code from another programmer and style differences aside, they do something I don't.

On every single reference to the class' own variables and methods, they precede it with this. (ie. this.Init() x Init() )

On my side, I've mostly used this to pass a reference to the instance to other classes, or, on occasion, when I needed to differentiate from base.

Is there any particular advantage in explicitly referring to this every time?

Taly Hotimsky
  • 221
  • 3
  • 8
  • 2
    It's helpful if you're getting paid by the number of characters you type. Otherwise, no. – STLDev Apr 17 '18 at 14:30
  • It might be nice for Intellisense to pick up faster on class-internals -but I despise it ;) – Patrick Artner Apr 17 '18 at 14:32
  • if requirements change forcing you to refactor a method and make it run in several threads at the same time, `this.ClassObject` let's you spot those land mines that can be overseen easily but cause problems at runtime where you can spend a lot of time searching for the reason... – Mong Zhu Apr 17 '18 at 14:42
  • StyleCop's default configuration requires `this` be specified on all internal member references. It's super annoying, but some people insist on following StyleCop religiously, without really thinking things through. – Bradley Uffner Apr 17 '18 at 14:50

1 Answers1

0

No functional difference. Perhaps the project coding style guidelines require it, in which case you should use it.

Tom Gullen
  • 61,249
  • 84
  • 283
  • 456