1

これについて Stack Overflow で多くの質問が回答されていることは知っているので、これらの解決策が実際に私にとってうまくいったかどうか、この質問をするつもりはありません。ここに私が見たいくつかの質問があります:

一貫性のないアクセシビリティ エラー C#

一貫性のないアクセシビリティ: プロパティ タイプ

上記の質問に対する各解決策に従って、すべてのクラスをパブリックとして指定しましたが、それでも同じエラーが発生します。これが私のコードです:

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

他の人のソリューションが私のケースでうまくいかない理由を誰か知っていますか? どんな助けでも大歓迎です!

4

1 に答える 1