This & Me, how nessicary are they?

Denaes

Senior Contributor
Joined
Jun 10, 2003
Messages
956
I got this ADO.Net book (by microsoft, its not that great) and a LOT of the examples are using Me and This like there was no tomorrow.

Me.Textbox1.Text

This.DataAdaptor.Connection

are these really required, or was the author just anal?

I want to keep up good OOP programming habits and I wasn't sure if this is something that would be more helpful/vital in the future with classes?
 
In classes, Me and this are the only way to reference the class from the "outside", and show that you are accessing something that belongs to your current class.
So, yes they are helpful/vital. (esp. when you get into OOP)
:)
 
Alright. So I guess its a good practice to start using them, even when not needed. Makes for easier Copy/Pasting of code and reinforces the habit so you don't go accidently referring to something you didn't want to.
 
Personally I see no point in using Me to refer to a member of the class, from within that class. I sometimes do it when I want some intellisense of all the members, but even then I'll delete it afterwards. I just don't see the point of having it there in those circumstances.
 
I've never used This, but I always make a point of using the Me prefix.

Must be force of habit??
 
hog said:
I've never used This, but I always make a point of using the Me prefix.

Must be force of habit??

This is the C# equivilant of Me in VB. Like Divil said, I really only use Me if I want the intellisense, however, I usually don't go back a delete it...just too lazy I 'spose...
 
I always use Me for calling a function or property accessor in the class, but I never use it for variables. I suppose it's just left-over habits from VB6.
 
Back
Top