|
Prefixing this. for members is a Microsoft .NET programming style guideline. I've tried to use it as often as I can remember to.
|
|
|
|
|
|
I did some searching but could not find that any more. Looks like they don't have a single document any more. This was from several years back. Once you installed the StyleCop plugin (was not part of VS then), it would issue warnings when you accessed a member without prefixing this.
|
|
|
|
|
Nish Sivakumar wrote: StyleCop
|
|
|
|
|
Heh
Not everyone's cup of tea, I know.
|
|
|
|
|
|
I've gone both ways, and both points are valid. I find myself using this a lot in JavasScript for some reason, but in C# I seldom do. For me, my biggest peeve is inconstancy in a project. So, looks like one of y'all are going to have to give in, or you could have him off'ed.
Jeremy Falcon
|
|
|
|
|
I think it's tip 97 in the How to Make C# Look Like Java guide.
I wanna be a eunuchs developer! Pass me a bread knife!
|
|
|
|
|
|
Errrm, this.
Alberto Brandolini: The amount of energy necessary to refute bullshit is an order of magnitude bigger than to produce it.
|
|
|
|
|
Only assignment, call, increment, decrement, and new object expressions can be used as a statement.
Your time will come, if you let it be right.
|
|
|
|
|
I do that. I prefer to type more up front and scratch my head less later.
That it honks off some members here is frosting on the cake.
|
|
|
|
|
My preference is to never use this unless there is a reason to do so (like conflicting names).
My methods are small enough that it is rarely a problem to see what is local and what is a property
and anyway, properties begin with a Capital and locals don't.
For static methods I use the classname. option, as there is no other obvious differentiator. That said, I don't work with many classes with static methods, so not something I have formed a habit out of.
When I see
this.SomeProperty = this.SomeMethod(this.SomeOtherProperty)
I cringe, and think "this? What else?)
PooperPig - Coming Soon
|
|
|
|
|
|
I do that sometimes....
And I don't really care either way...
And sometimes it's necessary when function parameter has the same name as class field!
|
|
|
|
|
I do not care about these redundancy but, personally, I do not prefer these type of redundant code.
___ ___ ___
|__ |_| |\ | | |_| \ /
__| | | | \| |__| | | /
|
|
|
|
|
By that same reasoning, stop using any "using" and reference only via fully qualified "System.Windows.Forms.ListCtrl.Item item" who needs any shortening of a line, just buy BLACK FRIDAY 50" MONITOR THATS IT?
|
|
|
|
|
Nareesh1 wrote: fully qualified "System.Windows.Forms.ListCtrl.Item item" Even when you say "fully qualified", there is no such thing as "System.Windows.Forms.ListCtrl.Item"..
Nareesh1 wrote: who needs any shortening of a line Oh the irony!
Your time will come, if you let it be right.
|
|
|
|
|
Yep, I know.
But I prefer not to include any Namespaces, only class names (the class name should be clear enough anyway).
I understand that in the new version of C# you can create a using for a class so you can use its static members without specifying the class. It's already my least favourite feature!
My blog[ ^]
public class SanderRossel : Lazy<Person>
{
public void DoWork()
{
throw new NotSupportedException();
}
}
|
|
|
|
|
Whenever there is the slightest chance of ambiguity, otherwise i prefer to keep it short.
Wrong is evil and must be defeated. - Jeff Ello
(√-sh*t) 2
|
|
|
|
|
Unless I have a construct like:
public class X{
private int number;
public X(int number){
this.number = number;
}
}
I rarely uses this .
|
|
|
|
|
I would say to use the property assignment 'this' in the following scenario:
void foo(int someValue)
{
this.someValue = someValue;
this.SomeMethod(AnotherClass.SomeMethod());
}
But not in the following scenario:
void foo()
{
someValue = 5;
SomeMethod(5);
}
With ThisClass.SomeStaticMethod() I'd always use is as you did unless of course you are using the static method of the class you are working in, then I'd just use SomeStaticMethod.
"Program testing can be used to show the presence of bugs, but never to show their absence."
<< please vote!! >>
|
|
|
|
|
this is good and I use it normally. The fact that it seems to annoy some pooples just encourages me to use it more.
|
|
|
|
|
such a trouble maker and non-conformist.
|
|
|
|
|
"this." triggers any auto-completion or Intellisense in the world. Yes I'm lazy - I wouldn't train machines to do men's work if I wasn't
|
|
|
|