這篇文章主要介紹了VB.NET如何自定義屬性,具有一定借鑒價(jià)值,感興趣的朋友可以參考下,希望大家閱讀完這篇文章之后大有收獲,下面讓小編帶著大家一起了解一下。
樂(lè)亭網(wǎng)站建設(shè)公司創(chuàng)新互聯(lián),樂(lè)亭網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為樂(lè)亭上1000家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站建設(shè)要多少錢(qián),請(qǐng)找那個(gè)售后服務(wù)好的樂(lè)亭做網(wǎng)站的公司定做!
類(lèi)文件:(Class1)
Imports System
Imports System.Reflection
< AttributeUsage(AttributeTargets.
All, AllowMultiple:=True,
Inherited:=True)> _Public Class Class1
Inherits System.Attribute
Private FamilyName As String
Private GivenName As String
Public Sub New(ByVal Family
Name As String)Me.FamilyName = FamilyName
End Sub
Public Overrides Function
ToString() As StringReturn 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
使用VB.NET自定義屬性的文件(Form3.VB)
< Class1("Watkins", Given:="Damien"),
Class1("Abrams")> _Public Class Form3
Inherits System.Windows.Forms.Form
Private Sub Button1_Click(ByVal sender
As System.Object, ByVal e As System.
EventArgs) Handles Button1.ClickDim t As TypeType = Type.GetType
("WindowsApplication6.Form3")Dim attributes As Object() =
t.GetCustomAttributes(True)Console.WriteLine("Custom
Attributes are: ")For Each o As Object
In attributesConsole.WriteLine(o)
Next
End Sub
End Class
感謝你能夠認(rèn)真閱讀完這篇文章,希望小編分享的“VB.NET如何自定義屬性”這篇文章對(duì)大家有幫助,同時(shí)也希望大家多多支持創(chuàng)新互聯(lián),關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,更多相關(guān)知識(shí)等著你來(lái)學(xué)習(xí)!
標(biāo)題名稱(chēng):VB.NET如何自定義屬性
文章URL:http://jinyejixie.com/article36/jjpipg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供小程序開(kāi)發(fā)、網(wǎng)站營(yíng)銷(xiāo)、網(wǎng)站收錄、服務(wù)器托管、手機(jī)網(wǎng)站建設(shè)、網(wǎng)站設(shè)計(jì)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶(hù)投稿、用戶(hù)轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話(huà):028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)