gpt4 book ai didi

c# - 字典的值 c# .net

转载 作者:太空宇宙 更新时间:2023-11-03 14:16:11 25 4
gpt4 key购买 nike

public class Response
{
public User[] Users { get; set; }
}
public class User
{
public string Uid { get; set; }
public string First_Name { get; set; }
public string Last_Name { get; set; }
public int Online { get; set; }
public int[] Lists { get; set; }
}

private void c_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
lock (this)
{
string json = e.Result;
// var response = JsonConvert.DeserializeObject(json);
var response = JObject.Parse(json);
// var COUNT = JsonConvert.DeserializeObject<List<User>>(json);
// MessageBox.Show(response.ToString());

var getcount = response["response"].Children<JObject>();
int count_friends=getcount.Cast<JToken>().Values("uid").Count();
Response rr = new Response();
for (int i = 0; i <count_friends; i++) {
//rr.Users.ToDictionary(rr.Users[i].Uid => response["response"][i]["uid"].ToString());
// rr.Users[i].First_Name = response["response"][i]["first_name"].ToString(); --DOESN'T WORKS
// Debug.WriteLine("OUT: "+(string)response["response"][i]["uid"].ToString());
//Debug.WriteLine("OUT: " + COUNT.Count());

}
Debug.WriteLine(rr.Users.ToString());
// string[] names = rr.Users.Select(d => d.First_Name).ToArray();

// string[] uids = response.Users.Select(d => d.Uid).ToArray();
// Dictionary<string,string> users = response.Users.ToDictionary(d => d.First_Name);
// Dictionary<string, string> usersById = response.Users.ToDictionary(d => d.Uid, d => d.First_Name);
}
}

我需要访问像“从 Response.User all where Online==1”这样的字典但是一开始我如何使用上面的类创建一个 DB(linq)?存储在 response["response"][i]["uid"],response["response"][i]["first_name"]...

中的所有值

最佳答案

这是你要找的吗?

Dictionary<string,List<Dictionary<string,object>>>

这是各种糟糕的设计,尝试重新思考问题以提出更好的解决方案

关于c# - 字典的值 c# .net,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6535422/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com