Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inconsistent accessibility error C#

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.

like image 744
Ari Avatar asked Oct 18 '11 10:10

Ari


2 Answers

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.

like image 141
C.Evenhuis Avatar answered Nov 14 '22 11:11

C.Evenhuis


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
{
    // ...
}
like image 32
Daniel Hilgarth Avatar answered Nov 14 '22 11:11

Daniel Hilgarth