【发布时间】:2021-07-02 19:31:29
【问题描述】:
我正在尝试使用来自第二个类的值和多维数组创建对象。我创造了什么:
class ProductData
{
private ProductPrices[] prices;
public string ParentName { get; set; }
public string Name { get; set; }
public string Description { get; set; }
public string TechnicalDescription { get; set; }
public bool Obsolete { get; set; }
public bool Deleted { get; set; }
public string Innercarton { get; set; }
public string Outercarton { get; set; }
public string Package { get; set; }
public string Barcode { get; set; }
public decimal Weight { get; set; }
public decimal EndUserPrice { get; set; }
public int MOQ { get; set; }
public bool ComingSoon { get; set; }
public bool NewProduct { get; set; }
public string Equivalent { get; set; }
public string ReplacedBy { get; set; }
public ProductPrices[] Prices
{
get
{
return prices;
}
set
{
prices = value;
}
}
public List<ProductFeatures> Feature { get; set; }
public List<string> Specification { get; set; }
public List<string> Image { get; set; }
public string File { get; set; }
public string Icon { get; set; }
}
class ProductFeatures
{
public string Feature;
}
public class ProductPrices
{
public decimal Price;
public int MinQuantity;
public DateTime validuntil;
public string currency;
}
现在我想为 ProductPrices 设置一个多维数组。 所以,最后我会有这样的东西:
Dictionary<string, ProductData> productInfo = new Dictionary<string, ProductData>();
//Adding data to productInfo
string productName = productInfo.Name;
string description = productInfo.Description;
decimal wholesalePrice = productInfo.ProductPrices[0].Price;
int minQty = productInfo.ProductPrices[0].MinQuantity;
某处我错过了一些东西。我一直在寻找几个小时试图找到它,但不幸的是...... 提前致谢!
【问题讨论】:
-
std::vector<ProductPrices> Prices是你想要的吗? -
我在您的代码中没有看到需要二维气道的任何地方。看起来你只是不知道如何使用字典。你能解释一下你的问题吗?
标签: c# arrays class multidimensional-array