开发者

Json Array - retrieve first record in C#

I am obtaining a JSON array in a dynamic object. How can I obtain the first item( equiv开发者_如何学运维alent of First for List collection)? How can I check if Json array is empty


If that's all you want to do with it, and if the underlying object implements IEnumerable, you could use:

foreach (dynamic item in array)
{
    // Use it here
    break;
}

Or use First explicitly:

dynamic first = Enumerable.First(array);
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜