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

ASP.NET
Asp.Net使用POST方法最简单的实现
实现.NET应用程序的自动更新
优秀ASP.NET程序员修炼之路
ASP.NET中实现模板页
在ASP.Net 2.0中实现多语言界面的方法
小议优化ASP.NET应用性能之Cache篇
.net开发投票机的思路
浅析CMS内容管理系统的两种方案
ASP.NET 2.0中动态修改页面标题
“您无权查看该网页”的原因和解决方法
将一个图片按比例缩放显示在一个Frame中
编程使用资源文件实现多语言页面(In Action)
.Net编程的多个小技巧
asp.net2.0学习历程-菜鸟到中级程序员的飞跃
asp.net如何连接sql server2000数据库
FCKeditor 2.6在ASP.NET中的配置方法
使用ASP.NET开发移动通讯的几种方法
ASP.NET 2.0的URL映射的实现方法
如何在Asp.net中使用HtmlArea编辑器
ASP.NET 2.0 中实现跨页提交

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-11-03   浏览: 55 ::
收藏到网摘: 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