我有三個類。所有都是同一個命名空間的一部分。這裏是三個類的基礎知識。由於其保護級別,無法訪問該類
//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' 不可訪問由於其保護級別
是指在FBlock以下行。 cs文件
private List<Method> pMethods;
and
'StubGenerator.PropGenerator.Method' 不可訪問由於其保護水平
其是指在FBlock.cs以下行文件
public Method AddMethod(string aName)
和
不一致的可訪問性:返回類型'StubGenerator.PropGenerator.Method'比方法'StubGenerator.PropGenerator .FBlock.AddMethod(串)」
是指在FBlock.cs以下行文件
public Method AddMethod(string aName)
使得類的方法公開不能解決錯誤。我無法弄清楚爲什麼我在調用Property類時沒有得到錯誤。我不明白爲什麼公開Method方法不能解決問題。
任何想法?
編輯問。在文件中是否可以設置一些導致此問題的設置?
如果您明確聲明主類是公共的,它會改變什麼嗎? – Bobby 2010-09-08 13:21:21
'Property'構造函數引用一個不存在的字段'pPropertyAttributes'。您明確沒有發佈產生您聲明的錯誤的代碼。 – Timwi 2010-09-08 13:28:09
這是FBlock定義結束時缺少的複製粘貼錯誤嗎?正如目前列出的,第一個名稱空間聲明未關閉。 – epotter 2010-09-08 13:29:05