【发布时间】:2014-12-18 00:36:46
【问题描述】:
我有一个名为 Attributes 的类
public class Attributes
{
public string Length { get; set; }
public string Size { get; set; }
public string Color { get; set; }
public string Material { get; set; }
public string Diameter { get; set; }
}
此类是通过调用返回 JSON 的 Web 服务填充的。 Web 服务每次都返回一组不同的属性,并且不可能在编译时定义所有属性,因为这可能会达到数千个。
在 c# 中为此类建模的最佳方法是什么?
【问题讨论】:
-
获得数据后你想用它做什么?
-
你试过字典吗?
-
把它们(或封装它们的东西)塞进字典里?
-
这个问题已经在这里回答了 load 次了,你有没有费心去读任何东西?