Sorry if this is a bad questions, but does it matter if I use,
this.Request.QueryString or just Request.QueryString to get my url
parameters? Will they both do the same?
Tom P. - 27 Feb 2008 21:23 GMT
No, they are not the same. One has a more explicit scope than the
other.
In a general sense you can do this fine with no problems but if you
have a scope change you may get different results.
In other words, if, for some reason, there is an instance or local
variable named "Request" it will conflict with the global Request
object. The odds of this happening are slim (since this is a reserved
word as well as an object name) but that's the difference - scope.
Tom P.
> Sorry if this is a bad questions, but does it matter if I use,
> this.Request.QueryString or just Request.QueryString to get my url
> parameters? Will they both do the same?
Peter Bromberg [C# MVP] - 27 Feb 2008 21:27 GMT
The "this" keyword is a reference to the instance of the class you are "in".
So for the example you show, it should not matter. "this" also can be used to
disambiguate a local variable or argument from a field:
public class TestMe
{
string name;
public TestMe (string name)
{
this.name = name;
}
}
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short Urls & more: http://ittyurl.net
> Sorry if this is a bad questions, but does it matter if I use,
> this.Request.QueryString or just Request.QueryString to get my url
> parameters? Will they both do the same?