【发布时间】:2015-09-30 15:59:39
【问题描述】:
我需要一种方法来跟踪网格中的行数和列数。如果我使用 System.Point,我总是会忘记“x”是行数还是列数。所以我有下面的课程。
但我想知道是否有一种方法可以使用 System.Point,并具有不同的命名皮肤?换句话说,我确实不想在 System.Point 上定义一个通用的“NRows”或“NColumns”方法。但我确实希望能够返回一个代码将视为“NRowsColumns”对象的对象,但实际上编译为 System.Point。在访问“NRowsColumns”对象时,我们使用字段“NRows”和“NColumns”而不是“x”和“y”。但在后台,它实际上编译为 System.Point。
理想情况下,此定义不限于单个文件。
public class NRowsColumns
{
public int NRows {get;set;}
public int NColumns {get;set;}
public NRowsColumns(int nRows, int nColumns)
{
this.NRows = nRows;
this.NColumns = nColumns;
}
}
【问题讨论】: