我是 Windows 手机的新手。
我将四个值存储在Dictionary<string, object>
. 当我检查条目时完成后,它会显示 7 个条目,其中三个是空键和值。
代码:
Dictionary<string, string> obj = new Dictionary<string, string>();
private void button1_Click(object sender, RoutedEventArgs e)
{
obj.Add("K2", "V2");
obj.Add("K3", "V3");
obj.Add("K4", "V4");
obj.Add("K5", "V5");
}
有什么帮助吗?
我用完字典的代码:
private void GetLoginCallback(IAsyncResult asynchronousResult)
{
try
{
Dictionary<string,object> Parameters = new Dictionary<string,object>();
/**httprequest for making asynchronous call**/
HttpWebRequest httpRequest = (HttpWebRequest)asynchronousResult.AsyncState;
/**response from the httprequest**/
HttpWebResponse httpresponse = (HttpWebResponse)httpRequest.EndGetResponse(asynchronousResult);
/**Reading the response as stream**/
Stream streamResponse = httpresponse.GetResponseStream();
using(StreamReader streamRead = new StreamReader(streamResponse))
{
var response = streamRead.ReadToEnd();
//Deployment.Current.Dispatcher.BeginInvoke(new Action(() =>
//{
if (response != null && httpresponse.StatusCode == HttpStatusCode.OK)
{
WebHeaderCollection headers = httpresponse.Headers;
/**getting Session_ID **/
string session_cookie = headers[DisplayMessage.Set_Cookie];
string sessionCookie = headers[DisplayMessage.Set_Cookie];
string[] values = sessionCookie.Split(DisplayMessage.Split_SemiCollen);
string[] jID = values[0].Split(DisplayMessage.Split_EqualTo);
jsessionId = jID[1];
/**storing Authentication parameters in dictionary**/
Parameters.Add("Username", "test4");
Parameters.Add("Password", "*****");
Parameters.Add("JSessionID", "FGBfdhhfuhuhhbh_Path");
Parameters.Add("SessionCookie","FGBfdhhfuhuhhbh_Path;dpk");
//}));
};
}
}
catch(Exception ex)
{
}
}