将属性添加到POCO属性以映射x,y单元格 [英] Adding attributes to POCO properties for mapping x,y cells
本文介绍了将属性添加到POCO属性以映射x,y单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
public class MyClass { public string MyProperty{ get; set; }
现在,我想将每个属性映射为一个[X,Y]整数.
Now, I would like to Map each property to have an [X, Y] integer.
MyProperty = "Its string value.";
MyProperty.X = 4;
MyProperty.Y = 10;
我正在考虑采取几种方法,但是不确定哪种方法最好.基本上将POCO映射到Excel电子表格.
There are a couple of ways I am thinking about doing this, but not sure what would be the best. Basically mapping a POCO to an Excel spreadsheet.
我应该还是可以装饰属性? 我应该使用字典吗?
Should I or can I decorate the properties? Should I use a Dictionary?
推荐答案
如@DavidHoerster所述,您需要一个更具描述性的类模型:
As @DavidHoerster mentioned, you need a more descriptive class model:
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..."
};
这篇关于将属性添加到POCO属性以映射x,y单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文