I have the following initialization of a constructor:
public partial class WizardPage1 : WizardPage
{
public WizardPage1()
: base(0, getLocalizedString(this.GetType(), "PageTitle"))
{
}
}
where
public static string getLocalizedString(Type type, string strResID)
{
}
but this.GetType()
part causes the following error:
error CS0027: Keyword 'this' is not available in the current context
Any idea how to resolve it?
The 'this' keyword refers to the current instance of the class. In the constructor, you don't have access to the instance because you are about to create one... So try below:
public partial class WizardPage1 : WizardPage
{
public WizardPage1()
: base(0, getLocalizedString(typeof(WizardPage1), "PageTitle"))
{
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With