新聞中心
這里有您想知道的互聯(lián)網(wǎng)營(yíng)銷解決方案
舉例介紹VB.NET類屬性詳細(xì)內(nèi)容
也許還有很多人對(duì)于VB.NET這樣一款編程語(yǔ)言還不太了解。它是一款功能成強(qiáng)大的語(yǔ)言,直接面向?qū)ο?,并且可以?chuàng)造一個(gè)結(jié)構(gòu)性比較牢固的編程化境。我們今天要為大家介紹的是VB.NET類屬性相關(guān)概念。其中有以下幾種需要舉例的。#t#

創(chuàng)新互聯(lián)主營(yíng)運(yùn)城網(wǎng)站建設(shè)的網(wǎng)絡(luò)公司,主營(yíng)網(wǎng)站建設(shè)方案,重慶APP軟件開(kāi)發(fā),運(yùn)城h5微信小程序開(kāi)發(fā)搭建,運(yùn)城網(wǎng)站營(yíng)銷推廣歡迎運(yùn)城等地區(qū)企業(yè)咨詢
VB.NET類屬性1、
- Public Property Rank() As String
'注意這里的屬性名后面有個(gè)括號(hào) - Get
- Return strPos
- End Get
- Set(ByVal value As String)
- strPos = value
- End Set
- End Property
VB.NET類屬性2、
- Public ReadOnly Property rHobby() As
String 'Readonly要在Property前面- Get
- Dim i As Integer
- Dim s As String
- s = Join(strHobby, ",")
'這個(gè)函數(shù)就是用來(lái)連接數(shù)組中的字符串的- Return s
- End Get
- End Property
VB.NET類屬性3、
- '這是定義索引器呀!
- Public ReadOnly Property indexHobby
(ByVal index As Integer) As String- Get
- If (strHobby Is Nothing) Or (index >
UBound(strHobby)) Then- '注意到上面的UBound()了沒(méi)?還有LBound()!
- '它們所在的命名空間是Microsoft.VisualBasic
- Return Nothing
- End If
- Return strHobby(index)
- End Get
- End Property
VB.NET類屬性4、
- Public WriteOnly Property wHobby()
As String- Set(ByVal value As String)
- If value Is Nothing Then
- If Not (strHobby Is Nothing) And
strHobby.GetLength(0) > 1 Then- ReDim Preserve strHobby(UBound
(strHobby) - 1)- End If
- Else
- If strHobby Is Nothing Then
- ReDim strHobby(0)
- Else
- ReDim Preserve strHobby(UBound
(strHobby) + 1)- End If
- strHobby(UBound(strHobby)) = value
- End If
- End Set
- End Property
5、
- Default Public Property Words
(ByVal index As Integer) As
String'注意Default- Get '注意到參數(shù)了嗎?使用這個(gè)屬性的時(shí)候,
就跟實(shí)現(xiàn)了索引器效果一樣。- Words = theWords(index)
- End Get
- Set(ByVal value As String)
- theWords(index) = value
- End Set
- End Property
文章標(biāo)題:舉例介紹VB.NET類屬性詳細(xì)內(nèi)容
文章源于:http://www.5511xx.com/article/cogspgo.html


咨詢
建站咨詢
