我想创建一个 try catch,以便如果提要不存在或由于某种原因无法创建,它将返回 false 或 null,以便我可以测试变量并创建默认项。
Function GetFeed(url As String) As SyndicationFeed
Dim feed = New SyndicationFeed
Try
Dim reader = XmlReader.Create(url)
feed = SyndicationFeed.Load(reader)
Catch ex As Exception
feed = Nothing
End Try
Return feed
End Function
它说我不能将类型“SyndicationFeed”设置为布尔值。
错误在于以下代码:
Dim feedUrl = "http://rss.news.yahoo.com/rss/entertainment"
Dim feed As SyndicationFeed = GetFeed(feedUrl)
If feed = Nothing Then
End If
它说,“未为 SyndicationFeed 类型定义运算符'='。”