enum 使用描述
来源:互联网 发布:js滑动杆打分特效 编辑:程序博客网 时间:2024/06/07 09:34
论坛问题贴:路径如下
http://social.microsoft.com/Forums/zh-CN/vbasiczhchs/thread/889fefb9-b98c-4a7a-86a2-c6359bd71cbb/?ffpr=0
Imports System
Imports System.Reflection Enum Coolness As Byte <Description("Not so cool")> _ NotSoCool = 5 Cool End Enum Class Description Inherits Attribute Public Text As String Public Sub New(ByVal text__1 As String) Text = text__1 End Sub End Class Module Module1 Private Function GetDescription(ByVal en As [Enum]) As String Dim type As Type = en.[GetType]() Dim memInfo As MemberInfo() = type.GetMember(en.ToString()) If memInfo IsNot Nothing AndAlso memInfo.Length > 0 Then Dim attrs As Object() = memInfo(0).GetCustomAttributes(GetType(Description), False) If attrs IsNot Nothing AndAlso attrs.Length > 0 Then Return DirectCast(attrs(0), Description).Text End If End If Return en.ToString() End Function Sub Main(ByVal args As String()) Dim coolType1 As Coolness = Coolness.Cool Dim coolType2 As Coolness = Coolness.NotSoCool Console.WriteLine(GetDescription(coolType1)) Console.WriteLine(GetDescription(coolType2)) Console.ReadLine() End Sub End Module- enum 使用描述
- enum使用
- enum使用
- Enum使用
- enum使用
- Enum使用
- enum类型添加自定义的描述方法
- 读取Enum的类型和描述
- Enum使用方法,为什么使用typedef enum--转载
- C - enum和typedef enum的使用
- enum和enum class的使用
- C# 使用Enum
- hibernate使用enum类型。
- ibatis中使用Enum
- Java Enum 使用
- enum、Static使用
- Enum使用demo
- 枚举类型-enum使用
- Debug是王道……
- asp.net如何在页面加载时响应回车事件
- 大幅优化 eclipse+myeclipse 速度
- 关于RedHat Linux各版本介绍
- Selenium IDE introduce
- enum 使用描述
- IBM--人的力量
- IT行业的良心不过关啊
- Access数据库产生ldb文件锁定文件解决办法!
- firefox与IE对javascript和CSS的区别
- 转贴文章: 悟透JavaScript
- 开博第一天
- 测试
- IE与FireFox的js和css (杂记)