I am obtaining a JSON array in a dynamic object. How can I obtain the first item( equivalent 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);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.