简体   繁体   中英

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)

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. You cannot use methods/class members from a base class that have been marked private. Try marking it 'protected'.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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