Reputation: 337
I created User class but when i want to take array of user objects, i face Inconsistent accessibility field type is less accessible than field error this is my code:
namespace CRUD.Model
{
class User
{
public int id { get; set; }
}
}
namespace CRUD
{
public partial class PurchasesBill : Form
{
public List<User> userList = new List<User>();
}
}
Upvotes: 0
Views: 2965
Reputation: 149548
You need to make your User
class public
:
public class User
{
public int Id { get; set; }
}
By default, if no access modifier is specified for the given class, it is internal
.
Upvotes: 9
Reputation: 3470
A public
class cannot have any publicly visible types (i.e. public
or protected
properties or fields) in it that themselves aren't public
. Your User
class is publicly visible through your userlist
field, but the User
class isn't public
. Hence the error.
Upvotes: 2