我知道在Stack Overflow上有很多關於此問題的問題,所以如果這些解決方案真的適合我,我不會問這個問題。這裏有一些問題我已經看了:不一致的可訪問性,屬性類型
Inconsistent accessibility error C#
Inconsistent accessibility: property type
我指定我所有的類爲公共,按每個解決上述問題,但我米仍然得到相同的錯誤。這裏是我的代碼:
namespace TestResourceManager
{
public class ViewModel
{
private List<string> m_ViewOptions = null;
private List<MachineRow> m_ViewChoices = null;
public ViewModel()
{
m_ViewOptions = new List<string>();
m_ViewOptions.Add("item1");
m_ViewOptions.Add("item2");
m_ViewChoices.Add(new MachineRow("machinename1", "builddefinition1", "description1", "envname1", "envtype1"));
m_ViewChoices.Add(new MachineRow("machinename2", "builddefinition2", "description2", "envname2", "envtype2"));
}
public List<string> ViewOptions
{
get { return m_ViewOptions; }
}
public List<MachineRow> ViewChoices
{
get { return m_ViewChoices; }
}
}
public class MachineRow
{
private string MachineName, BuildDefinition, Description, EnvName, EnvType;
public MachineRow(string _MachineName, string _BuildDefinition, string _Description, string _EnvName, string _EnvType)
{
this.MachineName = _MachineName;
this.BuildDefinition = _BuildDefinition;
this.Description = _Description;
this.EnvName = _EnvName;
this.EnvType = _EnvType;
}
}
}
此錯誤:
Inconsistent accessibility: property type 'System.Collections.Generic.List<TestResourceManager.ViewModel.MachineRow>' is less accessible than property 'TestResourceManager.ViewModel.ViewChoices'
該線路存在的:
public List<MachineRow> ViewChoices
有誰知道爲什麼其他人的解決方案是不是我的案子?任何幫助非常感謝!
該代碼在我的機器上編譯時沒有任何問題。你嘗試過重建還是清理/建造? –
對我來說似乎很好+1,用於清潔/重建。也許值得點擊'MachineRow'並導航到定義,並有可能避免一些錯誤(如果有衝突的定義是錯誤的)。 – Chris
這不是完整的代碼 - 錯誤信息是說''ViewModel'裏面有一個名爲'MachineRow'的內部類 –