由于其保护级别,MainWindow Vbox 无法访问 [英] MainWindow Vbox inaccessible due to its protection level
问题描述
我正在使用 Monodevelop 制作一个 gtk#2 应用程序.
I am making a gtk# 2 application using Monodevelop.
我制作了一个简单的 GUI,将一个 Window 和一个 Vbox 作为它的子项,以便在运行时使用它并在以后添加更多内容.
I have made a simple GUI, with a Window and a Vbox as its child in order to use it from the runtime and add more stuff later on.
似乎我无法从代码访问 vbox.
It seems though that i cannot access the vbox from the code.
这是代码:
namespace test
{
class MainClass
{
public static void Main (string[] args)
{
Application.Init ();
MainWindow win = new MainWindow ();
TreeView tree = new TreeView ();
Console.WriteLine(win.Child.Name);
Mainvbox=win.vbox2;
...
}}}
我得到的错误是这样的:错误 CS0122:MainWindow.vbox2"由于其保护级别(CS0122)(测试)而无法访问
The error i get is this: Error CS0122: `MainWindow.vbox2' is inaccessible due to its protection level (CS0122) (test)
推荐答案
vbox2 可能是私有/受保护的,编写一个属性访问器以在 MainWindow 的类中返回它(或在 MainWindow 代码中访问它).
vbox2 may be private/protected, write a property accessor to return it in MainWindow's class (or access it within MainWindow code).
这篇关于由于其保护级别,MainWindow Vbox 无法访问的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!