When NOT TO USE 'this' keyword?
Posted
by LifeH2O
on Stack Overflow
See other posts from Stack Overflow
or by LifeH2O
Published on 2010-05-15T21:22:08Z
Indexed on
2010/05/15
21:34 UTC
Read the original article
Hit count: 307
Sorry for asking it again, there are already 3 questions about this keyword. But all of them tell the purpose of 'this'.
My question is when not to use 'this' keyword .
OR
Is it all right to use this keyword always in situation like the code
class RssReader
{
private XmlTextReader _rssReader;
private XmlDocument _rssDoc;
private XmlNodeList _xn;
protected XmlNodeList Item { get { return _xn; } }
public int Count { get { return _count; } }
public bool FetchFeed(String url)
{
this._rssReader = new XmlTextReader(url);
this._rssDoc = new XmlDocument();
_rssDoc.Load(_rssReader);
_xn = _rssDoc.SelectNodes("/rss/channel/item");
_count = _xn.Count;
return true;
}
}
here i have not used 'this' with "_xn" and "_count" also not with "_rssDoc.Load(_rssReader);" is it fine? Should i use "this" with all occurrences of class variables within the class?
© Stack Overflow or respective owner