我需要一種方法來跟蹤網格中的行數和列數。如果我使用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;
}
}
關於命名的好建議。如果OP需要'NumberOfRows',那麼將其用作屬性名稱;否則就使用'行'。 「NRows」令人困惑。 –