public abstract class Parser
{
protected List<string> Tables { get; set; }
protected string TableName { get; }
public List<List<object>> Table { get; protected set; }
public Parser()
{
Tables = GetListOfTables();
Program.PrintCollection(Tables);
TableName = Program.GetUserChoose(Tables);
Table = GetTable();
}
protected abstract List<string> GetListOfTables();
protected abstract List<List<object>> GetTable();
}
在构造函数中或直接在属性设置器中为属性赋值的正确方法是什么?在我看来,立即在属性中更合乎逻辑,但您也可以在构造函数中设置它。也许有一些潜规则?查看内置类的描述,并没有发现很多立即设置属性的情况。