I want to create a try catch so that if the feed does not exist or cannot be created for some reason, it will return false or null so that I can then test the variable and create a default item.
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
It says I can’t set type “SyndicationFeed” to boolean.
The error is with this code:
Dim feedUrl = "http://rss.news.yahoo.com/rss/entertainment"
Dim feed As SyndicationFeed = GetFeed(feedUrl)
If feed = Nothing Then
End If
It says, “operator ‘=’ is not defined for type SyndicationFeed.”
In VB.Net you need to use the is operator to compare objects
So change your condition to: