【发布时间】:2018-01-22 11:33:10
【问题描述】:
我是 C# 的新手,我有一个问题
我有一个这样的类模型:
public class SDView
{
public int ViewPK { get; set; }
public string Code { get; set; }
public string Name { get; set; }
public string ConceptOrder { get; set; }
}
最后一个属性,ConceptOrder 包含一串数字,每个数字需要映射到不同的属性值...
例子:
Being ConceptOrder = "1,2,3,5,4"
public class Item
{
public string Warehouse { get; set; } //concept 1
public string Commodity { get; set; } //concept 2
public string Variety { get; set; } //concept 3
public string Packstyle { get; set; } //concept 4
public string Size { get; set; } //concept 5
}
我需要做的是编写一个返回的方法或函数(基于上面的例子)
“Warehouse01 BellPepper Green JUMBO 7x1”
ConceptOrder 可以是任意顺序,但每个数字都映射到某个 Property(1 始终是 Warehouse...2 始终是 Commodity)
显然这个例子被简化了
我无法理解这个
任何帮助将不胜感激!
编辑:
正是我想要做的是,我有具有属性的类模型:
SDView 类的ConceptOrder 属性包含这些属性必须在字符串属性中显示的顺序
所以我需要一个函数/方法,我可以在其中传递一个 ConceptOrder ("2, 3, 1, 4, 5") 并返回一个格式化字符串...
public class Item
{
public string Warehouse { get; set; } //concept 1
public string Commodity { get; set; } //concept 2
public string Variety { get; set; } //concept 3
public string Packstyle { get; set; } //concept 4
public string Size { get; set; } //concept 5
public string GetProductFromView(string conceptOrder)
{
...
return "CommodityPropValue VarietyPropValue WarehousePropValue.. etc"
}}
【问题讨论】:
-
ConceptOrder的示例数据和预期输出是什么?到目前为止,您尝试过什么? -
不是 100% 确定您要做什么,您能否进一步澄清问题?
标签: c# arrays function properties mapping