加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

c# – 错误CS0027:关键字’this’在当前上下文中不可用

发布时间:2020-12-16 01:57:30 所属栏目:百科 来源:网络整理
导读:参见英文答案 Keyword ‘this’ (Me) is not available calling the base constructor????????????????????????????????????4个 我有一个构造函数的以下初始化: public partial class WizardPage1 : WizardPage{ public WizardPage1() : base(0,getLocalize
参见英文答案 > Keyword ‘this’ (Me) is not available calling the base constructor????????????????????????????????????4个
我有一个构造函数的以下初始化:

public partial class WizardPage1 : WizardPage
{
    public WizardPage1()
        : base(0,getLocalizedString(this.GetType(),"PageTitle"))
    {
    }
}

哪里

public static string getLocalizedString(Type type,string strResID)
{
}

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

error CS0027: Keyword ‘this’ is not available in the current context

知道怎么解决吗?

解决方法

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

public partial class WizardPage1 : WizardPage
{
    public WizardPage1()
        : base(0,getLocalizedString(typeof(WizardPage1),"PageTitle"))
    {
    }
}

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读