Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Languages / C# / February 2008

Tip: Looking for answers? Try searching our database.

the this. on requests

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Cindy Lee - 27 Feb 2008 21:15 GMT
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?

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.