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

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/

10-12 20:04