Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error CS0027: Keyword 'this' is not available in the current context [duplicate]

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?

like image 690
c00000fd Avatar asked Sep 26 '13 03:09

c00000fd


1 Answers

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"))
    {
    }
}
like image 114
Damith Avatar answered Sep 24 '22 03:09

Damith