473,378 Members | 1,351 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

What is "this" ?

WJ
What is "this" that is being used by many asp and asp.net web applications
and is there "that" object some where ? Googled what is that and was not
satisfied @ all !

I know for sure that in c#, I donot need "this" and the thing still works
correctly as expected ! Is there a very good reason to use "this" notation
on every line ?

John
Nov 19 '05 #1
5 1091
"WJ" <Jo*******@HotMail.Com> wrote in
news:uj**************@TK2MSFTNGP14.phx.gbl:
What is "this" that is being used by many asp and asp.net web
applications and is there "that" object some where ? Googled
what is that and was not satisfied @ all !

I know for sure that in c#, I donot need "this" and the thing
still works correctly as expected ! Is there a very good reason
to use "this" notation on every line ?

http://msdn.microsoft.com/library/de...l=/library/en-
us/csref/html/vclrfThisPG.asp

or

http://tinyurl.com/3zk9d
--
Hope this helps.

Chris.
-------------
C.R. Timmons Consulting, Inc.
http://www.crtimmonsinc.com/
Nov 19 '05 #2
Normally, you don't need "this", as C# prefixes "this." by default.

However, say you have a member variable and a local variable with the
same name:

class TheUseOfThis : IUntestedExample
{
private string a;

public void MyFunction()
{
string a;

this.a = "assigned to member var";
a = "assigned to local var";
}
}

As you can see you need this to assign to the member variable.

There is no that in C#, of course.

Greetings,
Wessel

-----Original Message-----
From: WJ [mailto:Jo*******@HotMail.Com]
Posted At: Sunday, April 10, 2005 3:50 AM
Posted To: microsoft.public.dotnet.framework.aspnet
Conversation: What is "this" ?
Subject: What is "this" ?

What is "this" that is being used by many asp and asp.net web
applications
and is there "that" object some where ? Googled what is that and was not

satisfied @ all !

I know for sure that in c#, I donot need "this" and the thing still
works
correctly as expected ! Is there a very good reason to use "this"
notation
on every line ?

John
Nov 19 '05 #3
WJ
Thanks.

John
Nov 19 '05 #4
WJ
Thanks Wessel, that explains it. I better off use unique variables to avoid
being verbose and for ease of debugging..

John
Nov 19 '05 #5
:this" is a convenience, much like "using" which enables the developer to
omit namespaces. While it is generally not necessary, there are times when
conflicting names and namespaces make the use of "this" helpful. It can also
make your code easier to read.

--
HTH,

Kevin Spencer
Microsoft MVP
..Net Developer
What You Seek Is What You Get.

"WJ" <Jo*******@HotMail.Com> wrote in message
news:uj**************@TK2MSFTNGP14.phx.gbl...
What is "this" that is being used by many asp and asp.net web applications
and is there "that" object some where ? Googled what is that and was not
satisfied @ all !

I know for sure that in c#, I donot need "this" and the thing still works
correctly as expected ! Is there a very good reason to use "this" notation
on every line ?

John

Nov 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Jaime Wyant | last post by:
Will someone explain this to me? >>> "test".find("") 0 Why is the empty string found at position 0? Thanks! jw
3
by: Hodad | last post by:
I would like to adapt, as much as possible, the appearance and color red of the font in this button: <P><CENTER><BUTTON VALUE="SUBMIT"><A...
9
by: aden | last post by:
I have read the years-old threads on this topic, but I wanted to confirm what they suggest. . . Can the this pointer EVER point to a type different from the class that contains the member...
9
by: Player | last post by:
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hello all. I am in the process of teaching myself C# and I think I am doing OK. I have learnt how to how to call the right constructor of a...
1
by: Shapper | last post by:
Hello, I am accessing a value in a XML value: news.Load(Server.MapPath("xml/ news.rss")) newslabel.Text = CType(news.SelectSingleNode("rss version=&quot;2.0 &quot;/channel/title").InnerText, String) ...
7
by: relient | last post by:
Question: Why can't you access a private inherited field from a base class in a derived class? I have a *theory* of how this works, of which, I'm not completely sure of but makes logical sense to...
10
by: craig.keightley | last post by:
I am trying to get the next row within a loop for a script i am developing... I need to display a final table row within the table that i have displayed on the page, but i only want to show it...
1
by: Ray | last post by:
Hello, Please help a VB newbie :) I'm a bit confused, reading all the MyClass, Me, My keywords of VB. I think I get MyClass and My, but Me... Can you just tell me if I get this correctly? ...
5
by: anEchteTrilingue | last post by:
Hi everybody. Thank you for reading my post. I am having trouble getting "this" to work in all versions of IE (it's fine in Firefox, opera, konqueror, etc). What I would like to do is add an...
7
by: Joe | last post by:
usually slide bars move by "jumps" while scrolling which looks not nice. I came accress slide bar with price menu, ewnt through script/web source code, and could not find anything that would case...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.