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);
精彩评论