偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

舉例介紹VB.NET類屬性詳細(xì)內(nèi)容

開發(fā) 后端
初學(xué)者們可能正在苦于對VB.NET類屬性的相關(guān)概念無法很好的理解。不要緊,這篇文章就以幾段代碼示例來為大家詳細(xì)解讀其中含義。

也許還有很多人對于VB.NET這樣一款編程語言還不太了解。它是一款功能成強(qiáng)大的語言,直接面向?qū)ο螅⑶铱梢詣?chuàng)造一個結(jié)構(gòu)性比較牢固的編程化境。我們今天要為大家介紹的是VB.NET類屬性相關(guān)概念。其中有以下幾種需要舉例的。#t#

VB.NET類屬性1、

 

  1. Public Property Rank() As String 
    '注意這里的屬性名后面有個括號  
  2. Get  
  3. Return strPos  
  4. End Get  
  5. Set(ByVal value As String)  
  6. strPos = value 
  7. End Set  
  8. End Property 


 

VB.NET類屬性2、

  1. Public ReadOnly Property rHobby() As 
    String 'Readonly要在Property前面  
  2. Get  
  3. Dim i As Integer  
  4. Dim s As String  
  5. s = Join(strHobby, ",") 
    '這個函數(shù)就是用來連接數(shù)組中的字符串的  
  6. Return s  
  7. End Get  
  8. End Property 

 

VB.NET類屬性3、

  1. '這是定義索引器呀!  
  2. Public ReadOnly Property indexHobby
    (ByVal index As Integer) As String  
  3. Get  
  4. If (strHobby Is Nothing) Or (index > 
    UBound(strHobby)) Then  
  5. '注意到上面的UBound()了沒?還有LBound()!  
  6. '它們所在的命名空間是Microsoft.VisualBasic  
  7. Return Nothing  
  8. End If  
  9. Return strHobby(index)  
  10. End Get  
  11. End Property 

VB.NET類屬性4、

 

  1. Public WriteOnly Property wHobby() 
    As String  
  2. Set(ByVal value As String)  
  3. If value Is Nothing Then  
  4. If Not (strHobby Is Nothing) And 
    strHobby.GetLength(0) 
    > 1 Then  
  5. ReDim Preserve strHobby(UBound
    (strHobby) - 1)  
  6. End If  
  7. Else  
  8. If strHobby Is Nothing Then  
  9. ReDim strHobby(0)  
  10. Else  
  11. ReDim Preserve strHobby(UBound
    (strHobby) + 1)  
  12. End If  
  13. strHobby(UBound(strHobby)) = value  
  14. End If  
  15. End Set  
  16. End Property 

 

 

5、

 

  1. Default Public Property Words
    (ByVal index As Integer) As 
    String'注意Default  
  2. Get '注意到參數(shù)了嗎?使用這個屬性的時候,
    就跟實現(xiàn)了索引器效果一樣。
    <ClassObj(index)> 
  3. Words = theWords(index)  
  4. End Get  
  5. Set(ByVal value As String)  
  6. theWords(index) = value  
  7. End Set  
  8. End Property 

 

責(zé)任編輯:曹凱 來源: 博客園
相關(guān)推薦

2009-10-28 09:55:29

VB.NET MyCl

2010-01-21 16:45:00

VB.NET繼承規(guī)則

2009-10-12 15:02:51

VB.NET動態(tài)控件

2010-01-07 15:18:10

VB.NET常量

2009-11-10 12:42:47

VB.NET Prin

2010-01-13 16:15:47

VB.NET消息隊列

2010-01-11 15:43:06

VB.NET類屬性

2010-01-08 13:35:35

VB.NET寫Log方

2010-01-18 11:20:13

VB.NET默認(rèn)屬性

2009-11-10 12:48:17

VB.NET三維模型

2010-01-08 09:43:21

VB.NET漢字轉(zhuǎn)換

2010-01-22 14:19:38

VB.NET調(diào)用jar

2010-01-14 18:22:05

VB.NET硬盤速度測

2010-07-06 15:54:30

VB.NET UDP

2010-01-08 14:14:27

VB.NET使用Fin

2010-01-13 10:53:24

VB.NET控件

2009-10-13 17:03:55

VB.NET面向?qū)ο?/a>

2009-11-02 15:45:03

VB.NET IEnu

2009-10-12 13:54:22

VB.NET Data

2009-10-10 16:44:52

VB.NET開發(fā)控件
點(diǎn)贊
收藏

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