Microsoft Visual Studio 2017 for Mac Preview安装使用案例分(3)

using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using System.Web.Mvc.Ajax; namespace HelloWorldMVC.Controllers { public class HomeController : Controller { public ActionResult Index() { var users = new[] { new User(){ Id=1001,, Email="778078163@qq.com" }, new User(){ Id=1002,, Email="katelinna@qq.com" }, new User(){ Id=1003,, Email="mangseng@qq.com" }, new User(){ Id=1004,, Email="moganna@qq.com" }, new User(){ Id=1005,, Email="shangjin@qq.com" } }; ViewBag.Users = users; return View(); } } }

  修改Views/Home/Index.cshtml代码,显示刚刚存入的数组信息:

@if(ViewBag.Users==null) { <p>暂无资料。</p> } else { <table> <thead> <tr> <th>编号</th> <th>姓名</th> <th>邮箱</th> </tr> </thead> <tbody> @foreach(var item in ViewBag.Users) { <tr> <td>@item.Id</td> <td>@item.Name</td> <td>@item.Email</td> </tr> } </tbody> </table> }

  点击运行: 

  哎呦我XXXX。打开Views/Shared/Layout.cshtml,果然,设置编码格式,添加meta修改如下:

<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>@ViewBag.Title</title> </head> <body> @RenderBody() </body> </html>

  再次运行: 

  OK,完事儿~

5. 软件下载

 Visual Studio for Mac Preview Installer.dmg 链接: https://pan.baidu.com/s/1miwKtW8 密码: ivtu

Visual Studio For Mac Preview1 7.0.0.347.dmg 链接: https://pan.baidu.com/s/1boNkTor 密码: nu5x

6. 结尾

  哈哈,到此,案例都测试完了,感觉还不错。

  只是有一点,貌似自带的没有窗体应用程序。。。

  好了,各位可以自己玩玩,有啥问题下面留言 咱们一起交流交流感情。哈哈。

更多精彩内容大家可以点击《Visual Studio 2017开发使用教程》,关于visual studio的安装教程可以点击《Visual Studio安装使用手册》进行学习,希望大家喜欢。

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wjyzds.html