开发者

Json Array - retrieve first record in C#

开发者 https://www.devze.com 2023-03-29 07:47 出处:网络
I am obtaining a JSON array in a dynamic object. How can I obtain the first item( equiv开发者_如何学运维alent of First for List collection)?

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

精彩评论

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