I have a class with a private set to List<string>
, so I can not set this list.
This is my class:
public class PaginationReturn<T>
{
public PaginationReturn()
{
this.Errors = new List<string>();
this.Success = true;
}
public IEnumerable<T> Data { get; set; }
public Boolean Success { get; private set; }
public List<string> Errors { get; private set; }
public void AddError(String mensagem)
{
this.Errors.Add(mensagem);
this.Success = false;
}
}
I don't want to allow to do something like this, but this compiles without error:
paginationReturn.Errors.Add("Error!!");
I want to force to use this method to add items to a list:
paginationReturn.AddError("Error!!");