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

ASP.NET
浅析.NET 3.5 SP1中的JIT增强
在ASP.Net中实现RSA加密
浅析ASP.NET中C++和J#的混合应用
探讨ASP.NET MVC框架内置AJAX支持编程技术
Web开发模式的颠覆者:ASP.NET MVC
设计ASP.NET应用程序的七大绝招
浅谈Asp.net多层架构中的变量引用与传递
ASP.NET遍历配置文件的连接字符串
ASP.NET2.0中配置文件的加密与解密
Ja.Net:融合 Java 1.5 和 .NET
ASP.NET 2.0 中XML数据的处理
ASP.NET中备份SQL Server数据库的方法
asp.net/c#字符格式化
在.NET应用程序中进行Erlang风格的并行编程
Flex与.NET互操作:基于WebService的数据访问
asp.net 里 include UTF8 垃圾问题
让.Net程序脱离.Net Framework框架运行
.NET上执行多线程应该注意的两点
ASP.NET应该遵守的9条代码编写规范
.Net和Java的socket机制比较

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


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