Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/325.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何选择Bing新闻结果的类别?_C#_Web Services_Bing - Fatal编程技术网

C# 如何选择Bing新闻结果的类别?

C# 如何选择Bing新闻结果的类别?,c#,web-services,bing,C#,Web Services,Bing,嗨,我正在尝试从Bing提供的8个类别中的1个中检索新闻(Bing搜索API) 检查文档 根据文档,它应该包含一个字符串,其中包含上面页面中列出的一个值。但每次我应用它时: request.Query = "Football"; request.Sources = new SourceType[] { SourceType.News }; request.News.Category = "rt_ScienceAndTechnology";//Error comes here 这将返回一个“空引

嗨,我正在尝试从Bing提供的8个类别中的1个中检索新闻(Bing搜索API)

检查文档

根据文档,它应该包含一个字符串,其中包含上面页面中列出的一个值。但每次我应用它时:

request.Query = "Football";
request.Sources = new SourceType[] { SourceType.News };
request.News.Category = "rt_ScienceAndTechnology";//Error comes here

这将返回一个“空引用异常”。任何回复和建议都将不胜感激。

我认为您需要在设置request.News.Category之前初始化request.News

request.News = new NewsRequest();

从此处开始:

请求是否已初始化。新闻是否已初始化?我猜是那个请求。新闻是空的