Two pretty simple bits of code. The top one is mine, the bottom one is a version that someone was actually pedantic enough to email me with to tell me to correct my work.
What angered me the most is probably that his doesn't even seem to be logical.. The setter seems redundant. Am I missing something??
c# code:
private bool? _isDataFeed;
public bool isDataFeed
{
get
{
if (_isDataFeed == null)
{
string header = Request.Headers["X-Requested-With"];
_isDataFeed = (!String.IsNullOrEmpty(header) && header.ToLower() == "xmlhttprequest");
}
return (bool)_isDataFeed;
}
set
{
_isDataFeed = value;
}
}
c# code:
private bool _isDataFeed;
public bool isDataFeed
{
get
{
string header = Request.Headers["X-Requested-With"];
_isDataFeed = (!String.IsNullOrEmpty(header) && header.ToLower() == "xmlhttprequest");
return _isDataFeed;
}
set
{
_isDataFeed = value;
}
}
|