Reputation: 462
This is my code :
var client = new FacebookClient(token);
dynamic result = client.Get("search?q=tbilisi&type=user", new { });
result.data is an array, how to determine if it's an empty array. For example what i'm trying to do :
while (true)
{
if (result == null)
{
break;
}
if (result.data == null )
{
break;
}
But not woks. When result.data = []
i want to check and break while loop.
Upvotes: 0
Views: 4806
Reputation: 83
This one works for me:
if (object == null || ((JArray)object).Count == 0) {
// code
}
Upvotes: 0
Reputation: 6219
while (true)
{
if (result == null)
{
break;
}
if (result.data == null || !result.data.Any())
{
break;
}
}
Upvotes: 1
Reputation: 24903
var array = result.data as Facebook.JsonArray;
if (array == null || array.Count == 0)
Upvotes: 9