请帮忙进行代码转换 [英] Please help on code conversion
问题描述
请各位精彩的人尝试将c#代码转换为vb.net。请通常使用developerfusion.com将我所有的c#代码转换为vb.net。但它给我的转换我不理解。我正在尝试制作列表集合。我正在关注MVC框架的Jon Galloway教程可在此URL上找到http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-3\">。代码在C#中,我只是一个学习者试着学习vb.net。下面是代码片段。如果有人能帮助我将它转换为Vb.net,将不胜感激。
Please wonderful people i am trying to convert a c# code to vb.net. Please i normally use developerfusion.com to convert all my c# code to vb.net.But the conversion it gave me i don''t understand it.I am trying to make a list collection.I am following Jon Galloway tutorial on MVC framework which is available on this URL http://www.asp.net/mvc/tutorials/mvc-music-store/mvc-music-store-part-3">. The code is in C# and i am just a learner trying to learn vb.net. Below is the code snippet.Will be grateful if any one can help me convert it to Vb.net.
public ActionResult Index()
{
var genres = new List<Genre>
{
new Genre { Name = "Disco"},
new Genre { Name = "Jazz"},
new Genre { Name = "Rock"}
};
return View(genres);
}
推荐答案
尝试以下(你可以肯定地优化它!):
Try the below(you can optimize it for sure!):
Public Function Index() As ActionResult
Dim genres As New List(Of Genre)
Dim oGenre1 As Genre
Dim oGenre2 As Genre
Dim oGenre3 As Genre
oGenre1 = New Genre()
oGenre2 = New Genre()
oGenre3 = New Genre()
oGenre1.Name = "Disco"
oGenre2.Name = "Jazz"
oGenre3.Name = "Rock"
genres.Add(oGenre1)
genres.Add(oGenre2)
genres.Add(oGenre3)
Return View(genres)
End Function
这篇关于请帮忙进行代码转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!