gpt4 book ai didi

c# - 收到错误 "No best type found for implicitly-typed array"

转载 作者:太空狗 更新时间:2023-10-29 21:18:38 27 4
gpt4 key购买 nike

这是我为 jqGrid 创建 Json 响应和用于定义单元格成员的 new 关键字的代码,我收到以下消息“找不到隐式类型数组的最佳类型”。

var resRows = results.Select(record => 
new
{
id = record.Reference,
cell = **new** []
{
record.Reference,
record.TradeDate.ToShortDateString(),
record.Currency1,
record.Currency2,
record.Notional.ToString(),
record.EffectiveDate.ToShortDateString(),
record.Quote.ToString()
}
}).ToArray();

我在这里做错了什么?

最佳答案

假设ReferenceCurrency1Currency2 是字符串,只需将其声明为字符串数组即可:

var resRows = results.Select(record => 

new
{
id = record.Reference,
cell = new string []
{
record.Reference,
record.TradeDate.ToShortDateString(),
record.Currency1,
record.Currency2,
record.Notional.ToString(),
record.EffectiveDate.ToShortDateString(),
record.Quote.ToString()
}
}).ToArray();

关于c# - 收到错误 "No best type found for implicitly-typed array",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11244819/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com