简体   繁体   English

为什么是InitializeComponent(); 由于其保护级别而无法访问?

[英]Why is InitializeComponent(); inaccessible due to its protection level?

So here's the current code that I have and I'm getting the error: 因此,这是我当前拥有的代码,并且出现错误:

'SampleWindows.BaseWindow.InitializeComponent()' is inaccessible due to its protection level (CS0122) 由于其保护级别,无法访问“ SampleWindows.BaseWindow.InitializeComponent()”(CS0122)

Any help? 有什么帮助吗?

using System;

namespace SampleWindows
{
    public class Form1 : BaseWindow
    {
        public Form1()
        {
            InitializeComponent();
            RoundedCorners(this.Height, this.Width);
        }
    }
}

It's because InitializeComponent is probably marked 'private' inside BaseWindow but here in your class Form1 you are trying to use it. 这是因为InitializeComponent可能在BaseWindow中被标记为“私有”,但是在您的类Form1中,您尝试使用它。 You cannot use methods/class members from a base class that have been marked private. 您不能使用来自基类的标记为私有的方法/类成员。 Try marking it 'protected'. 尝试将其标记为“受保护”。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM