I have a class with a property of type Dictionary<>. I am trying to initialize the property in the constructor using the following code. It gives error. Why?
Error 1
'Permissions' is a 'property' but is used like a 'type'
Code:
public class UserModel
{
public UserModel() // constructor
{
Permissions = new Permissions<Guid, List<Guid>();
}
public Dictionary<Guid, List<Guid>> Permissions { get; set; }
}
You cannot create instance of property. Instead you need to create instance of a type and assign it to property.
public class UserModel
{
public UserModel() // constructor
{
Permissions = new Dictionary<Guid, List<Guid>>();
}
public Dictionary<Guid, List<Guid>> Permissions { get; set; }
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With