Question

I would like to code using normal early binding datatypes rather than using dynamic (or var). However in order to enumerate using

foreach (var item in fbFeed.data) 

requires that fbFeed is a type which has a property 'data'

var fb = new Facebook.FacebookClient(longlifeaccess_token);
dynamic fbFeed = fb.Get("me/feed");

foreach (var item in fbFeed.data)
{
    var thepost = (IDictionary<string, object>)item;
    Console.WriteLine("ID {0}", thepost["id"].ToString());
}

What data types should I be using for fbFeed and item in the above code, if I do not want to use var or dynamic.

Was it helpful?

Solution

I think this should be close

Facebook.FacebookClient fb = new Facebook.FacebookClient(longlifeaccess_token);
Facebook.JsonObject feFeed = (Facebook.JsonObject)fb.Get("me/feed");
Facebook.JsonArray feFeedData = (Facebook.JsonArray)feFeed["data"];

foreach (Facebook.JsonObject item in feFeedData)
{
    IDictionary<string, object> post = (IDictionary<string, object>)item;

... ...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top