using system;
using system.data;
using system.configuration;
using system.collections;
using system.web;
using system.web.security;
using system.web.ui;
using system.web.ui.webcontrols;
using system.web.ui.webcontrols.webparts;
using system.web.ui.htmlcontrols;
public partial class default2 : system.web.ui.page
protected void button1_click(object sender, eventargs e)
//獲取列舉的名稱
string namelist = enum.getnames(typeof(week));
foreach (string s in namelist)
//獲取列舉的名稱
response.write(enum.getname(typeof(week),3)+"
");response.write(enum.getname(typeof(week), week.wednesday) + "
");//獲取列舉的基類
response.write(enum.getunderlyingtype(typeof(week)));
response.write(string.format("this is a good job ,and i need ", "dd", "s"));
}public enum week
}
使用列舉型別的值建立列舉型別
列舉型別中不僅可以宣告列舉的名稱,還可以加入附加的值如下式 public static enum pushtype public string tostring 其中push type sys稱為列舉的name,0則為列舉型別的value,那如何才能根據列舉型別的value獲取列舉型別的例項呢?見下...
iOS 列舉型別使用
引言 列舉值它是乙個整形 int 並且,它不參與記憶體的占用和釋放,列舉定義變數即可直接使用,不用初始化.在 中使用列舉的目的只有乙個,那就是增加 的可讀性.使用 列舉的定義如下 csharp view plain copy typedef enum test 列舉名稱 亦可以如下定義 推薦 結構比...
列舉型別的使用
1.列舉的定義列舉型別定義的一般形式為 enum 列舉名 在列舉值表中應羅列出所有可用值。這些值也稱為列舉元素。例如 該列舉名為weekday,列舉值共有7個,即一周中的七天。凡被說明為weekday型別變數的取值只能是七天中的某一天。2.列舉變數的說明 如同結構和聯合一樣,列舉變數也可用不同的方式...