天天看點

枚舉,Enum,正常使用demo記錄

using System;

using System.Collections.Generic;

using System.Linq;

using System.Web;

using System.Web.Mvc;

namespace MvcEnum.Controllers

{

public class HomeController : Controller

{

public ActionResult Index()

{

//int t=(int)TypeStyle.類型;

/////根據枚舉的值擷取對應的名稱

//TypeStyle t1 = (TypeStyle)1;

//TypeStyle t2 = (TypeStyle)2;

//TypeStyle t3 = (TypeStyle)3;

//ViewBag.Message = t3 +"//"+ t2+"//"+t3 + "修改此模闆以快速啟動你的 ASP.NET MVC 應用程式。";

int t = (int)TypeStyle.類型;

TypeStyle t1 = (TypeStyle)t;

ViewBag.Message = t1 + t + "修改此模闆以快速啟動你的 ASP.NET MVC 應用程式。";

return View();

}

public ActionResult About()

ViewBag.Message = "你的應用程式說明頁。";

public ActionResult Contact()

ViewBag.Message = "你的聯系方式頁。";

public enum TypeStyle{

類型=1,

周期=2,

判斷=3,

}

}

筆者原創!如果您覺得閱讀本文對您有幫助,請點一下“推薦”按鈕,您的“推薦”将是我最大的寫作動力!歡迎各位轉載,轉載請添加原部落格連接配接,否則保留追究法律責任的權利,謝謝!

YC.Boilerplate 快速開發架構交流,請加群:1060819005

區塊鍊交流請加QQ群:538327407(已滿),群2:135019400.

我的部落格位址:http://www.cnblogs.com/linbin524/