Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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?

  • Leaders
Posted

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)

:)

Iceplug, USN

One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(

Posted
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.
  • *Gurus*
Posted
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.

MVP, Visual Developer - .NET

 

Now you see why evil will always triumph - because good is dumb.

 

My free .NET Windows Forms Controls and Articles

Posted
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...

Being smarter than you look is always better than looking smarter than you are.
  • *Experts*
Posted
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.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...