开发者

Question about using Anonymous List Types

private 开发者_StackOverflowList<T> GetFieldList()
{
    var Fields = new { DisplayName = "MCP", FieldName = "t.MCP", FieldType = 1 };
    var FieldList = (new[] { Fields }).ToList();

    return FieldList;
}

Should I be able to do something like this?


If I understand correctly your tag "asp.net" this construction will be used as part of data binding. Just use non generic :

private IList GetFieldList()
{
    var Fields = new { DisplayName = "MCP", FieldName = "t.MCP", FieldType = 1 };
    IList FieldList = (new[] { Fields }).ToList();

    return FieldList;
}

It would be nice handled by all data-bound controls.


I just realized I don't need to use an anonymous list as I know the structure of the data I'm expecting, so I'll just create a small class for it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜