How would I change this C# code to VB.Net
public static List<YouTubeInfo> LoadVideosKey(string keyWord)
{
try
{
var xraw = XElement.Load(string.Format(SEARCH,keyWord));
var xroot = XElement.Parse(xraw.ToString());
var links = (from item in xroot.Element("channel").Descendants("item")
select new YouTubeInfo
{
LinkUrl = item.Element("link").Value,
EmbedUrl = GetEmbedUrlFromLink(item.Element("link").Value),
ThumbNailUrl = GetThumbNailUrlFromLink(item),
}).Take(20);
return links.ToList<YouTubeInfo>();
}
catch (Exception e)
{
Trace.WriteLine(e.Message, "ERROR");
}
return null;
}
I have used 4 different code converters plus mine and I still get the same thing back... Here is the code from mine...
Public Shared Function LoadVideosKey(keyWord As String) As List(Of YouTubeInfo)
Try
Dim xraw As Object = XElement.Load(String.Format(SEARCH, keyWord))
Dim xroot As Object = XElement.Parse(xraw.ToString())
Dim links As Object = (From item In xroot.Element("channel").Descendants("item")New YouTubeInfo() With { _
Key .LinkUrl = item.Element("link").Value, _
Key .EmbedUrl = GetEmbedUrlFromLink(item.Element("link").Value), _
Key .ThumbNailUrl = GetThumbNailUrlFromLink(item) _
}).Take(20)
Return links.ToList(Of YouTubeInfo)()
Catch e As Exception
Trace.WriteLine(e.Message, "ERROR")
End Try
Return Nothing
End Function
This is code from Sasha's YouTube Viewer which was coded in WPF. I am changing this over to a WinForms app and this is the only piece of code that I cant get to work.
I know that the word "Key" is not suppose to be in there after conversion, still does not work after removal. The main area of code that I am having the problem with is the ( "Dim links As Object = ......." )
Thanks for the help in advance...