我使用資料結構來存盤 JSON 資料
Class node
Friend ReadOnly position As Integer
Friend ReadOnly position_Array As Integer
Public index As Integer = 0
Friend head As String
Friend parent As node
Friend is_array_item As Boolean = False
' Friend attrib As node_val
Friend child_list As New List(Of node_val)
Friend tail As String
Sub New(ByRef a As node, ByRef pos As Integer) ', b As node_val)
parent = a
' attrib = b
position = pos ' a.child_list.Count - 1
End Sub
End Class
暗淡 n 作為新節點 n.child_list(8).val
dim n as new node
n.child_list(8).val
我想把這個類的物件句柄作為陣列
n(8).val
我是怎么做到的
uj5u.com熱心網友回復:
您可以向您的類添加一個默認屬性node,該屬性將從您的child_list:
Class node
Friend ReadOnly position As Integer
Friend ReadOnly position_Array As Integer
Public index As Integer = 0
Friend head As String
Friend parent As node
Friend is_array_item As Boolean = False
Friend child_list As New List(Of node)
Friend tail As String
Sub New(ByRef a As node, ByRef pos As Integer)
parent = a
position = pos
End Sub
''' <summary>
''' Gets or sets child node.
''' </summary>
''' <param name="index"></param>
Default Property Child(ByVal index As Integer) As node
Get
If index >= 0 And index < child_list.Count Then
Return child_list.Item(index)
Else
' index is out of bounds
Return Nothing
End If
End Get
Set(value As node)
If index < 0 Then Return
If index < child_list.Count Then
child_list.Item(index) = value
Else
' Add node at end of list
child_list.Add(value)
End If
End Set
End Property
End Class
請小心Child物業上的二傳手。串列中的專案應按順序插入。
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/468893.html
上一篇:React無法決議字串物件
