自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

VB.NET自定義屬性應(yīng)用方式解析

開發(fā) 后端
我們可以使用VB.NET自定義屬性的文件進行具體的代碼編寫,完成程序中需要的特定功能。在這里就為大家詳細介紹相關(guān)應(yīng)用方法。

VB.NET編程語言的出現(xiàn),在一定程度上改變了編程人員的編寫習(xí)慣,它靈活的編寫方式提高了編程效率。我們在這里就會為大家?guī)黻P(guān)于VB.NET自定義屬性的應(yīng)用方式,希望能方便大家的理解。

類文件:(Class1)

  1. Imports System   
  2. Imports System.Reflection   
  3. < AttributeUsage(AttributeTargets.
    All, 
    AllowMultiple:=True
    Inherited:=True)> _   
  4. Public Class Class1   
  5. Inherits System.Attribute   
  6. Private FamilyName As String   
  7. Private GivenName As String   
  8. Public Sub New(ByVal Family
    Name As String)   
  9. Me.FamilyName = FamilyName   
  10. End Sub   
  11. Public Overrides Function 
    ToString() As String   
  12. Return String.Format("Author:
    {0}{1}", FamilyName, GivenName)   
  13. End Function   
  14. Public Property Family() As String   
  15. Get   
  16. Return FamilyName   
  17. End Get   
  18. Set(ByVal Value As String)   
  19. FamilyName = Value   
  20. End Set   
  21. End Property   
  22. Public Property Given() As String   
  23. Get   
  24. Return GivenName   
  25. End Get   
  26. Set(ByVal Value As String)   
  27. GivenName = Value   
  28. End Set   
  29. End Property   
  30. End Class  

使用VB.NET自定義屬性的文件(Form3.VB)

  1. < Class1("Watkins", Given:="Damien"), 
    Class1("Abrams")
    > _   
  2. Public Class Form3   
  3. Inherits System.Windows.Forms.Form   
  4. Private Sub Button1_Click(ByVal sender 
    As System.Object, ByVal e As System.
    EventArgs) Handles Button1.Click   
  5. Dim t As TypeType = Type.GetType
    ("WindowsApplication6.Form3")   
  6. Dim attributes As Object() = 
    t.GetCustomAttributes(True)   
  7. Console.WriteLine("Custom 
    Attributes are: ")   
  8. For Each o As Object 
    In attributes   
  9. Console.WriteLine(o)   
  10. Next   
  11. End Sub   
  12. End Class  

VB.NET自定義屬性的具體應(yīng)用方式就為大家介紹到這里。

【編輯推薦】

  1. VB.NET異常迭代捕捉代碼示例
  2. VB.NET共享成員變量創(chuàng)建技巧解析
  3. 范例解讀VB.NET獲取環(huán)境變量
  4. VB.NET抓取網(wǎng)頁相關(guān)問題解決方法
  5. VB.NET讀取內(nèi)存具體代碼編寫方法
責(zé)任編輯:曹凱 來源: blue1000.com
相關(guān)推薦

2010-01-15 15:26:46

VB.NET自定義類型

2009-10-09 15:59:41

VB.NET對象

2010-01-19 13:36:16

VB.NET可選參數(shù)

2010-01-11 17:40:36

VB.NET相框效果

2009-10-27 11:16:20

VB.NET應(yīng)用框架

2010-01-15 15:03:23

VB.NET對象變量聲

2010-01-20 17:41:13

VB.NET標記語句

2010-01-11 17:58:36

VB.NET壓縮ZIP

2010-01-14 18:08:08

VB.NET抽象類

2010-01-12 18:12:58

VB.NET事件

2009-11-10 17:12:22

VB.NET自定義類型

2010-01-21 18:19:45

VB.NET條件編譯

2010-01-22 16:07:26

VB.NET Mid函

2009-10-26 15:26:37

VB.NET屬性

2010-01-21 13:11:31

VB.NET安裝工程

2009-10-13 09:24:57

VB.NET Dock

2009-10-28 10:51:32

VB.NET默認屬性

2009-10-14 11:15:06

VB.NET Grou

2009-11-02 14:48:45

VB.NET HOOK

2010-01-15 16:46:05

VB.NET集合存儲
點贊
收藏

51CTO技術(shù)棧公眾號