标题可能有点令人困惑,但我正在尝试做类似的事情,
public class Configurations
{
public int TableRow;
public int TableColumn;
public string TableName;
public void SaveSettings(){ }
public Configurations LoadSettings(){ }
}
当您为Configurations
类(来自另一个类)创建实例时,例如,
Configurations settings = new Configurations();
您可以访问课程中的所有属性,但我想将它们分组到另一个类中,比如Property
,
settings.TableRow // I do NOT want this visible/accessible here
settings.Property.TableRow // this is what I want instead
settings.SaveSetting(); // only the methods should be accessible on the parent
我不太确定如何通过继承或类上的属性赋值来完成此操作。有人可以给我一些指示吗?
答案 0 :(得分:1)
为什么不创建另一个包含此设置的类?
public class Configurations
{
public TableProperties Property = new TableProperties();
public void SaveSettings(){ }
public Configurations LoadSettings(){ }
}
public class TableProperties
{
public int TableRow;
public int TableColumn;
public string TableName;
}