t3hclwn
t3hclwn

Reputation: 37

Inconsistent accessibility, property type

I know there are many questions answered on Stack Overflow about this, so I wouldn't be asking this question if these solutions actually worked for me. Here are some of the questions I've looked at:

Inconsistent accessibility error C#

Inconsistent accessibility: property type

I've specified all of my classes as being public, as per each solution to the above questions, but I'm still getting the same error. Here is my code:

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;
        }
    }
}

This error:

Inconsistent accessibility: property type 'System.Collections.Generic.List<TestResourceManager.ViewModel.MachineRow>' is less accessible than property 'TestResourceManager.ViewModel.ViewChoices'

is occuring on this line:

public List<MachineRow> ViewChoices

Does anyone know why everyone else's solutions aren't working for my case? Any help much appreciated!

Upvotes: 1

Views: 1042

Answers (1)

Reed Copsey
Reed Copsey

Reputation: 564451

The code, as pasted, is not the complete code. Given the error message: System.Collections.Generic.List<TestResourceManager.**ViewModel**.MachineRow>, the issue is that there is an extra inner class, class MachineRow defined somewhere inside of your ViewModel class.

public class ViewModel
{
   // Somewhere before the closing brace, you're defining a MachineRow class that is not public, ie:
   class MachineRow {}

Upvotes: 2

Related Questions