排序并存储两个值

时间:2015-06-03 06:21:36

标签: c# linq

我必须存储大约10万件物品。它们中的每一个都包含两个值(字段?)

  DateTime, Decimal

我必须按DateTime排序这些项目。不过,我试试 失败 编译时错误

  List<DateTime, Decimal> list = ... // <- Compile time error
  ...
  list.Sort();

如何解决存储排序此类项目的问题?是否可以使用Linq?

1 个答案:

答案 0 :(得分:3)

首先,您不能像那样声明<xsl:value-of select="catalog/cd[1]/country"/>

 JsonSerializerSettings config = new JsonSerializerSettings { MetadataPropertyHandling = MetadataPropertyHandling.Ignore, ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore, ContractResolver = new ExcludeEntityKeyContractResolver() };
 string json = JsonConvert.SerializeObject(Model, Formatting.Indented, config);

因为List<T>只能有一个泛型参数(即 List<DateTime, decimal> list // compile time error )。 最受欢迎的解决方案是使用

List<T>

在你的情况下

T

所以实施可能是

  Tuple<T1, T2, ...>