Ari
Ari

Reputation: 1036

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.

Upvotes: 8

Views: 12948

Answers (2)

C.Evenhuis
C.Evenhuis

Reputation: 26446

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.

Upvotes: 16

Daniel Hilgarth
Daniel Hilgarth

Reputation: 174329

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
{
    // ...
}

Upvotes: 6

Related Questions