LeMixer
LeMixer
CC#
Created by LeMixer on 1/25/2023 in #help
✅ Make set accessor of inherited prop private
I have the following interface:
public interface IItemModel
{
public int Id { get; set; }
public string Name { get; set; }
public string ImageUrl { get; set; }
}
public interface IItemModel
{
public int Id { get; set; }
public string Name { get; set; }
public string ImageUrl { get; set; }
}
since methods in an interface can not be private, but I want the setter to be private I get CS0277 when trying this:
internal class FoodItemModel : IItemModel
{
public int Id { get; private set; }
}
internal class FoodItemModel : IItemModel
{
public int Id { get; private set; }
}
Is there a way to make the setter private?
41 replies