public class MyClass { public string MyProperty{ get; set; }
现在,我想将每个属性映射为[X,Y]整数。
MyProperty = "Its string value.";
MyProperty.X = 4;
MyProperty.Y = 10;
我正在考虑这样做的几种方法,但不确定什么是最好的。基本上将POCO映射到Excel电子表格。
我应该还是可以装饰属性? 我应该使用字典吗?
答案 0 :(得分:0)
正如@DavidHoerster所提到的,你需要一个更具描述性的类模型:
public class SpreadSheetCell
{
public int X {get; set;}
public int Y {get; set;}
public string Contents {get; set;}
}
...
SpreadSheetCell[,] spreadSheet = new SpreadSheetCell[100,100];
spreadSheet[1, 2] = new SpreadSheetCell
{
X = 1,
Y = 2,
Contents = "Something goes here..."
};