C#的Dictionary获取键与值

it2025-09-05  7

Dictionary<object, object> conents = KeyValueHelper.GetConentByString(data); //Dictionary //conents.Item("personId") //if ((conents.Keys.ToString()).Equals("personId")) //{ // MessageBox.Show("获取personId:" +conents["personId"] ); // GetPersonInfo(conents["personId"].ToString()); //} // Console.WriteLine(data); //Console.WriteLine("result:"); foreach (KeyValuePair<object, object> e in conents) { textBox1.AppendText(string.Format("Key : {0} Value : {1}", e.Key.ToString(), e.Value.ToString())); textBox1.AppendText("\r\n"); string value = e.Key.ToString().Trim(); if (e.Key.Equals("personId")) { // MessageBox.Show("获取personId:" + e.Value.ToString()); // MessageBox.Show("2获取personId:" +conents["personId"].ToString()); // } }

 

最新回复(0)