我该如何修复 CS0136?
How do i fix CS0136?
好的,我已经试了 4 个小时了。
我想要做的是获取此列表中的每个用户名(可以是与 userid 匹配的任何列表):
我想在控制台中看到的示例:
Username: sk2lly
以及用户id
好友列表中的所有其他用户
但我一直收到这个错误
CS0136: A local or parameter named 'temp' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
代码:
Console.WriteLine("UserId: ");
string UserId = Console.ReadLine();
Console.Clear();
WebClient client = new WebClient();
string useridtextbox1 = client.DownloadString("https://api.roblox.com/users/" + UserId + "/friends/");
dynamic fobj = JsonConvert.DeserializeObject<dynamic>(useridtextbox1);
string temp = fobj["Username"].ToString();
foreach (string temp in fobj)
{
Console.WriteLine(temp);
Console.ReadLine();
}
试试这个
foreach (var temp in fobj)
{
Console.WriteLine(temp.ToString());
Console.ReadLine();
}
好的,我已经试了 4 个小时了。
我想要做的是获取此列表中的每个用户名(可以是与 userid 匹配的任何列表):
我想在控制台中看到的示例:
Username: sk2lly
以及用户id
好友列表中的所有其他用户但我一直收到这个错误
CS0136: A local or parameter named 'temp' cannot be declared in this scope because that name is used in an enclosing local scope to define a local or parameter
代码:
Console.WriteLine("UserId: ");
string UserId = Console.ReadLine();
Console.Clear();
WebClient client = new WebClient();
string useridtextbox1 = client.DownloadString("https://api.roblox.com/users/" + UserId + "/friends/");
dynamic fobj = JsonConvert.DeserializeObject<dynamic>(useridtextbox1);
string temp = fobj["Username"].ToString();
foreach (string temp in fobj)
{
Console.WriteLine(temp);
Console.ReadLine();
}
试试这个
foreach (var temp in fobj)
{
Console.WriteLine(temp.ToString());
Console.ReadLine();
}