C#枚举的不常用方法Enum.Parse&Enum.GetNames
2011-07-21 16:00
267 查看
public enum OpType
{
Addnew,
Update,
Delete
}
public enum OpType
{
Addnew,
Update,
Delete
}
1.根据枚举列表名字字串取得对应的值。
string opStr = "Delete";
int result = (int)Enum.Parse(typeof(OpType), opStr);
string opStr = "Delete";
int result = (int)Enum.Parse(typeof(OpType), opStr);
2.将枚举转换为数组。
Enum.GetNames(typeof(OpType))(王朝网络 wangchao.net.cn)
{
Addnew,
Update,
Delete
}
public enum OpType
{
Addnew,
Update,
Delete
}
1.根据枚举列表名字字串取得对应的值。
string opStr = "Delete";
int result = (int)Enum.Parse(typeof(OpType), opStr);
string opStr = "Delete";
int result = (int)Enum.Parse(typeof(OpType), opStr);
2.将枚举转换为数组。
Enum.GetNames(typeof(OpType))(王朝网络 wangchao.net.cn)
相关文章推荐
- C#枚举的不常用方法Enum.Parse&Enum.GetNames
- C#_delegate - Pair<T> & 简单顺序逆序 & 方法委托(在Pair类下)&枚举类型 混搭使用
- C#编程:枚举(enum)与结构(struct)的定义和使用方法
- C# 枚举常用方法浅析
- java 几种常用的枚举(Enum)方法
- 14. JAVA 枚举(Enum、类集EnumMap&EnumSet 、实现接口、定义抽象方法) ----- 学习笔记
- C#+Enum 枚举扩展方法获取name,value和Description
- C#Enum常用枚举操作
- c# EnumHelper枚举常用操作类
- C#关于使用枚举遇到的问题----Parse()方法使用注意
- C#&.net常用方法集合
- 学习笔记---取得枚举项的2种方法: Enum.GetValues()-Array.GetValue()和Enum.GetNames()-Enum.Parse()
- C#枚举的常用使用方法
- C# 枚举常用工具方法
- c#枚举(Enum)的用法及遍历方法
- 枚举Enum 的常用方法
- c#枚举(Enum)的用法及遍历方法
- c#.net常用函数和方法集
- C#串口SerialPort常用属性方法
- C# ToString()常用方法