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'在当前上下文中不可用
知道怎么解决吗?
this关键字引用类的当前实例,在构造函数中你没有即时,你要创建一个..所以请尝试下面
public partial class WizardPage1 : WizardPage
{
public WizardPage1()
: base(0, getLocalizedString(typeof(WizardPage1), "PageTitle"))
{
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
8922 次 |
| 最近记录: |