Denaes Posted November 18, 2003 Posted November 18, 2003 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? Quote
Leaders Iceplug Posted November 18, 2003 Leaders Posted November 18, 2003 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) :) Quote Iceplug, USN One of my coworkers thinks that I believe that drawing bullets is the most efficient way of drawing bullets. Whatever!!! :-(
Denaes Posted November 18, 2003 Author Posted November 18, 2003 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. Quote
*Gurus* divil Posted November 18, 2003 *Gurus* Posted November 18, 2003 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. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
hog Posted November 18, 2003 Posted November 18, 2003 I've never used This, but I always make a point of using the Me prefix. Must be force of habit?? Quote My website
Mothra Posted November 18, 2003 Posted November 18, 2003 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... Quote Being smarter than you look is always better than looking smarter than you are.
*Experts* Volte Posted November 18, 2003 *Experts* Posted November 18, 2003 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. Quote
Administrators PlausiblyDamp Posted November 18, 2003 Administrators Posted November 18, 2003 Rarely use Me at all - except like Divil just to get the intellisense, tend to use this all the time in C# though. Go figure. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.