Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/292.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 字典<;字符串,字符串>;儿童词典_C#_Facebook - Fatal编程技术网

C# 字典<;字符串,字符串>;儿童词典

C# 字典<;字符串,字符串>;儿童词典,c#,facebook,C#,Facebook,看着 我想发布“地点”信息,如何将子节点/字典插入postArgs?我可以得到的基本信息张贴如下 Facebook.FacebookAPI api = new Facebook.FacebookAPI(GetAccessToken(code)); Dictionary<string, string> postArgs = new Dictionary<string, string>(); postArgs["name"] = myEvent.Title; postArg

看着 我想发布“地点”信息,如何将子节点/字典插入postArgs?我可以得到的基本信息张贴如下

Facebook.FacebookAPI api = new Facebook.FacebookAPI(GetAccessToken(code));

Dictionary<string, string> postArgs = new Dictionary<string, string>();
postArgs["name"] = myEvent.Title;
postArgs["description"] = myEvent.Content;
postArgs["start_time"] = myEvent.DateStart;
postArgs["end_time"] = myEvent.DateEnd;
postArgs["location"] = myEvent.Location; //myEvent.City;//";
postArgs["page_id"] = "1234567";

//  Dictionary<string, string> postVenue = new Dictionary<string, string>();
//  postVenue["city"] = myEvent.City;
//  postVenue["state"] = myEvent.County;
//  postVenue["country"] = "United Kingdom";
//  postVenue["latitude"] = myEvent.Latitude;
//  postVenue["longitude"] = myEvent.Longitude;

// here I need to add postVenue to postArgs as a child.

api.Post("/12345676788/events", postArgs);
Facebook.FacebookAPI=newfacebook.FacebookAPI(GetAccessToken(code));
Dictionary postArgs=新字典();
postArgs[“name”]=myEvent.Title;
postArgs[“description”]=myEvent.Content;
postArgs[“开始时间”]=myEvent.DateStart;
postArgs[“结束时间”]=myEvent.DateEnd;
postArgs[“location”]=myEvent.location//myEvent.城市//";
postArgs[“page_id”]=“1234567”;
//Dictionary postvince=新字典();
//赛后地点[“城市”]=myEvent.city;
//赛后地点[“州”]=myEvent.县;
//赛后场地[“国家”]=“英国”;
//赛后[“纬度”]=myEvent.纬度;
//赛后地点[“经度”]=myEvent.经度;
//在这里,我需要作为一个孩子将PostVincement添加到postArgs。
api.Post(“/123456788/events”,postArgs);

谢谢您的时间。

您不能在此处将字典放入postArgs中,因为您已将其声明为字符串的值类型。代码

Dictionary<string, string> postArgs = new Dictionary<string, string>()
Dictionary postArgs=new Dictionary()
指示它具有string类型的键和string类型的值。如果您希望能够存储多种类型的混合,则需要类似以下内容:

Dictionary<string, Object> postArgs = new Dictionary<string, Object>()
Dictionary postArgs=new Dictionary()

但是,这需要您在值退出字典时强制转换它们。

从您的代码中,我希望Post的签名是:

void Post(string, Dictionary<string,string>)
然后您可以这样添加它:

postArgs.Add("venues",venues);
然后去eialization将是

var venues = postArgs["venues"]
var postVenue = (from pair in venues.Split(',')
                 select pair.Split(':')
                ).ToDictionary(pair => pair[0],pair=>pair[1]);
var venues = postArgs["venues"]
var postVenue = (from pair in venues.Split(',')
                 select pair.Split(':')
                ).ToDictionary(pair => pair[0],pair=>pair[1]);