错误CS0027:关键字'this'在当前上下文中不可用

c00*_*0fd 4 .net c# constructor

我有一个构造函数的以下初始化:

public partial class WizardPage1 : WizardPage
{
    public WizardPage1()
        : base(0, getLocalizedString(this.GetType(), "PageTitle"))
    {
    }
}
Run Code Online (Sandbox Code Playgroud)

哪里

public static string getLocalizedString(Type type, string strResID)
{
}
Run Code Online (Sandbox Code Playgroud)

this.GetType()部分导致以下错误:

错误CS0027:关键字'this'在当前上下文中不可用

知道怎么解决吗?

Dam*_*ith 8

this关键字引用类的当前实例,在构造函数中你没有即时,你要创建一个..所以请尝试下面

public partial class WizardPage1 : WizardPage
{
    public WizardPage1()
        : base(0, getLocalizedString(typeof(WizardPage1), "PageTitle"))
    {
    }
}
Run Code Online (Sandbox Code Playgroud)