8

I'm getting an error with a property for a list. It's saying the list is less accessible than the property.. I'm not sure why I am getting this error..

//List
private List<Client> clientList = new List<Client>();

//Property
public List<Client> ClientListAccessor
{
    get 
    { 
        return clientList; 
    }
    set 
    { 
        clientList = value; 
    }
}

Thanks in advance for any help.

Ari
  • 1,026
  • 6
  • 20
  • 31

2 Answers2

16

Most probably Client is not a public class, and ClientListAccessor is publically accessible. The caller will have access to the property but wouldn't know the type it returns.

C.Evenhuis
  • 25,996
  • 2
  • 58
  • 72
6

That's happening, because the class Client is not defined as a public class. Make sure, the class definition looks like this:

public class Client
{
    // ...
}

In your code it probably looks like this:

class Client
{
    // ...
}

or like this (which is the same):

internal class Client
{
    // ...
}
Daniel Hilgarth
  • 171,043
  • 40
  • 335
  • 443