I was asked, what I thought was a simple question, until I thought about it.
"Is there ever a need for using Me. (VB.Net) or this. (C#) - when referring to properties belonging to the same scope?"
i.e. There are some legacy projects we work on and a co-worker was using class properties via Me.[Property]
- I noticed this and explained that he can simply access the property directly (remove the Me.
).
(VB.Net)
Public Property Name() As String
Me.Name = "My Name" vs. Name = "My Name"
(C#)
public string Name{ get; set; }
this.Name = "My Name"; vs. Name = "My Name";
I was wondering though, is there a reason (other than passing the entire class / object, which I believe is a different topic) that you would ever need to call Me.
or this.
Or is it simply legacy code left in place that causes no harm (has no positive or negative effect)?