than just to call the parameter as it is?
views:
380answers:
4If you mean fields, then no. The compiler injects "this" (ldarg.0) whether you use it explicitly (this.foo) or implicitly (foo).
It does, however, take 5 more characters in your source code... so a handful of bytes on your development hard disk. It will make exactly zero difference in the compiled IL or at runtime.
There are two scenarios where use of "this" changes things:
- when there is a variable/parameter with the same name (
this.foo = foo;
) - when resolving extension methods (
this.SomeMethod()
;)
I do not know, if it uses more memory, but I don't think so, its only a clear reference, something that would be done under the hood as well by the compiler.
I guess you mean before the variable name? I do not see why it would use more memory. The CLR must be optimize whatever the syntax is to refer to the variable to a way that it doesn't affect the performance (after verification, it will add the this...). So no it doesn't.
Your question is much too ambiguous to answer definitively but i would still start with a resounding No
then i'd want to know what exactly do you mean with parameter? I would normally interpret it as "argument to a method" but they are not tied to "this" within scope so you probably meant "members" such as fields, properties and/or methods.
If all of my assumptions about how to interpret your question are correct, I stand by my former "No".
But i would like to know where you got that idea from.