Possible Duplicate:
Why is the ‘this’ keyword required to call an extension method from within the extended class
Using Visual Studio 2012
Sitefinity 5.* defines a few extension methods for System.Web.UI.MasterPage
in the namespace Telerik.Sitefinity.Web.UI
.
If I include a reference to that namespace, I can use one particular extension method which indicates of a page is being rendered normally, or by the internal search engine:
using Telerik.Sitefinity.Web.UI;
namespace MyWebApp
{
public partial class MyMasterPage : System.Web.UI.MasterPage
{
protected void Page_Load(object sender, EventArgs e)
{
/// hide common page elements.
/// GetIndexRenderMode() returns "Normal" if the page is being rendered
/// normally, but not if the search engine is indexing the page.
if (this.GetIndexRenderMode() != IndexRenderModes.Normal)
{
headerPlaceholder.Visible = false;
footerPlaceholder.Visible = false;
navigationPlaceholder.Visible = false;
}
}
}
}
However, if I remove this
from the if(...)
statement, the compiler no longer finds the extension method.
What gives? I've never before seen a case where this
was necessary, except to resolve ambiguity between class members and interface members or parameters.