类是无法访问由于其保护级别

编程入门 行业动态 更新时间:2024-10-26 07:30:17
本文介绍了类是无法访问由于其保护级别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我有三个班。都是同一个命名空间的一部分。这里有三个班的基础知识。

I have three classes. all are part of the same namespace. here are the basics of the three classes.

//FBlock.cs namespace StubGenerator.PropGenerator { class FBlock : IDesignRegionInserts, IFormRegionInserts, IAPIRegionInserts, IConfigurationInserts, ISoapProxyClientInserts, ISoapProxyServiceInserts { private List<Property> pProperties; private List<Method> pMethods; public FBlock(string aFBlockName) { pProperties = new List<Property>(); pMethods = new List<Method>(); } public Property AddProperty(string aName) { Property loProp = new Property(this, aName, pProperties.Count); pProperties.Add(loProp); return loProp; } public Method AddMethod(string aName) { Method loMeth = new Method(this, aName); pMethods.Add(loMeth); return loMeth; } } //Method.cs namespace StubGenerator.PropGenerator { class Method : IPropertyName { private List<StubGenerator.PropGenerator.PropertyAttribute> pPropertyAttributes; private string pName; private string pFBlockName; public Method(FBlock aFBlock,string aName) { pPropertyAttributes = new List<PropertyAttribute>(); pName = aName; pFBlockName = aFBlock.Name; } } } //Property.cs namespace StubGenerator.PropGenerator { class Property : StubGenerator.PropGenerator.IPropertyName, StubGenerator.PropGenerator.IDesignRegionInserts, StubGenerator.PropGenerator.IFormRegionInserts, IAPIRegionInserts, IConfigurationInserts, ISoapProxyClientInserts, ISoapProxyServiceInserts { private string pName; private string pExpandedName; private string pFBlockInitials; private Group pPropertyGroup; private FlowLayoutPanel pGroupFlowPanel; private Button pUpdateButton; private CheckBox pShowProperty; private string pFBlockName; public Property(FBlock aFBlock, string aName, int aIndex) { pPropertyAttributes = new List<PropertyAttribute>(); pFBlockName = aFBlock.FBlockName; ExpandName(); GetInitials(); pShowProperty = new CheckBox(this, 10, (aIndex + 1) * 20, aIndex); pPropertyGroup = new Group(this); pGroupFlowPanel = new FlowLayoutPanel(this); pUpdateButton = new Button(this, 10, 18, aIndex); } } }

我收到以下错误

StubGenerator.PropGenerator.Method'不可访问由于其保护级别

'StubGenerator.PropGenerator.Method' is inaccessible due to its protection level

这是指在FBlock.cs以下行文件

which refers to the following line in the FBlock.cs file

private List<Method> pMethods;

StubGenerator.PropGenerator.Method'不可访问由于其保护级别

'StubGenerator.PropGenerator.Method' is inaccessible due to its protection level

这是指在FBlock.cs以下行文件

which refers to the following line in the FBlock.cs file

public Method AddMethod(string aName)

可访问性不一致:返回类型StubGenerator.PropGenerator.Method'比少的方法访问StubGenerator.PropGenerator.FBlock.AddMethod(字符串)

Inconsistent accessibility: return type 'StubGenerator.PropGenerator.Method' is less accessible than method 'StubGenerator.PropGenerator.FBlock.AddMethod(string)'

这是指在FBlock.cs以下行文件

which refers to the following line in the FBlock.cs file

public Method AddMethod(string aName)

制作类的方法公开不能解决错误。我想不通,为什么我调用的属性类时,没有得到错误。我不明白为什么制作方法类公众不解决问题。

making the class Method public does not resolve the errors. I can't figure out why I don't get the errors when calling the Property class. And I don't understand why making the Method class public doesn't fix the problem.

任何想法?

编辑问。莫不是对文件中的一些设置,导致此?

Edited to ask. could there be some setting on the file that causes this?

推荐答案

有是用于链接文件的项目。我需要的method.cs文件添加到该项目为链接文件为好,因为FBlock.cs文件在那里。我从来没有听说过链接的文件之前,我甚至不知道这是可能的。

There was a project that used linked files. I needed to add the method.cs file to that project as a linked file as well, since the FBlock.cs file was there. I've never heard of linked files before, I didn't even know that was possible.

更多推荐

类是无法访问由于其保护级别

本文发布于:2023-11-26 19:59:28,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1634981.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:于其   无法访问   级别

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!