【发布时间】:2016-01-12 18:23:54
【问题描述】:
这是我从 GitHub 下载的:https://gist.githubusercontent.com/Keeguon/2310008/raw/bdc2ce1c1e3f28f9cab5b4393c7549f38361be4e/countries.json 和 https://raw.githubusercontent.com/dominictarr/random-name/master/first-names.json
我的应用程序中有两个文本块,我想检查输入的国家名称和名字是否存在于列表中。
我希望应用程序处于脱机状态,因此我下载了这些文件。 JSON 真的很新。
还有其他选项可以填充名称国家等列表吗?
更新:我已经尝试了很多东西,包括下面马修回答中的代码。但我收到以下消息
Name Place Animal Thing.exe 中 0x75A86ABE (combase.dll) 处未处理的异常:0xC000027B:发生了应用程序内部异常(参数:0x097EF758、0x00000002)。
我尝试过这样的事情:
private void newbt_Click(object sender, RoutedEventArgs e)
{
List<Places> myPlaces = JsonConvert.DeserializeObject<List<Places>>("Assets/countries.json");
bool zimbabwe = myPlaces.Any(x => x.name == "Zimbabwe");
if (zimbabwe)
NTB.Text = "";
}
【问题讨论】:
-
查看:json.net,他们的文档中有一些教程可能会对您有所帮助。
-
您的问题是什么?无法理解您想要什么。