当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > 元数据--自定义属性(VB.NET)

ASP.NET
ASP.NET开发:简化应用程序的开发支持Web标准
asp.net XMLHttpRequest实现用户注册前的验证
asp.net 页面间传值方法小结
asp.net url重写浅谈
asp.net 验证码生成和刷新及验证
C#精髓 GridView72大绝技 学习gridview的朋友必看
实例说明asp.net中的简单角色权限控制
asp.net网站开发包wq.dll打包下载
js与ASP.NET 中文乱码问题
asp.net checkbox 动态绑定id GridView删除提示
asp.net TextBox回车触发事件 图片在img显示
asp.net 脏字典过滤问题 用正则表达式来过滤脏数据
asp.NET 脏字过滤算法
asp.NET 脏字过滤算法 修改版
asp.net sql 数据库处理函数命令
asp.net Javascript 的几种写法与提示
ASP.NET MVC学习笔记
asp.net 中国身份证号码验证代码 非正则
Asp.net中使用Sqlite数据库的方法
asp.net 中文字符串提交乱码的解决方法

ASP.NET 中的 元数据--自定义属性(VB.NET)


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 53 ::
收藏到网摘: n/a


类文件:(Class1)
Imports System
Imports System.Reflection
_
Public Class Class1
Inherits System.Attribute
Private FamilyName As String
Private GivenName As String
Public Sub New(ByVal FamilyName As String)
Me.FamilyName = FamilyName
End Sub
Public Overrides Function ToString() As String
Return String.Format("Author:{0}{1}", FamilyName, GivenName)
End Function
Public Property Family() As String
Get
Return FamilyName
End Get
Set(ByVal Value As String)
FamilyName = Value
End Set
End Property
Public Property Given() As String
Get
Return GivenName
End Get
Set(ByVal Value As String)
GivenName = Value
End Set
End Property
End Class
使用自定义属性的文件(Form3.vb)

_

Public Class Form3
Inherits System.Windows.Forms.Form

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim t As Type = Type.GetType("WindowsApplication6.Form3")
Dim attributes As Object() = t.GetCustomAttributes(True)
Console.WriteLine("Custom Attributes are: ")
For Each o As Object In attributes
Console.WriteLine(o)
Next
End Sub
End Class