Namespace System Namespace Collections Namespace ObjectModel Class ReadOnlyCollection Implements System.Collections.Generic.IList list As System.Collections.Generic.IList Public 'Collection クラスの新しいインスタンスを初期化します。 Sub ReadOnlyCollection () Dim l = New System.Collections.Generic.List This.list = l End Sub Sub ReadOnlyCollection ( list As System.Collections.Generic.IList ) This.list = list End Sub Public 'Collection に実際に格納されている要素の数を取得します。 Override Function Count () As Long Return This.list.Count() End Function 'Item 指定したインデックスにある要素を取得します。 Sub Operator[] ( index As Long, item As T ) Throw New NotSupportedException End Sub Function Operator[] ( index As Long ) As T Return This.list.Item(index) End Function Protected 'Collection をラップする IList ラッパーを取得します。 Function Items () As Generic.IList Return This End Function Public 'Collection の末尾にオブジェクトを追加します。 Override Sub Add ( item As T ) Throw New NotSupportedException End Sub 'Collection からすべての要素を削除します。 Override Sub Clear () Throw New NotSupportedException End Sub 'ある要素が Collection 内に存在するかどうかを判断します。 /* Function Contains ( item As T ) As Boolean End Function*/ 'Collection 全体を互換性のある 1 次元の Array にコピーします。コピー操作は、コピー先の配列の指定したインデックスから始まります。 /*CopyTo*/ 'Collection を反復処理する列挙子を返します。 Override Function GetEnumerator () As System.Collections.Generic.IEnumerator Return This.list.GetEnumerator() End Function '指定したオブジェクトを検索し、Collection 全体内で最初に見つかった位置の 0 から始まるインデックスを返します。 Override Function IndexOf ( item As T ) As Long Return This.list.IndexOf(item) End Function 'Collection 内の指定したインデックスの位置に要素を挿入します。 Override Sub Insert ( index As Long, item As T ) Throw New NotSupportedException End Sub 'IList が読み取り専用かどうかを示す値を取得します。 Override Function IsReadOnly () As Boolean Return True End Function 'Collection 内で最初に見つかった特定のオブジェクトを削除します。 Override Function Remove ( item As T ) As Boolean Throw New NotSupportedException End Function 'Collection の指定したインデックスにある要素を削除します。 Override Sub RemoveAt ( index As Long ) Throw New NotSupportedException End Sub '現在の Object を表す String を返します。 (Object から継承されます。) Override Function ToString () As String Dim string = New Text.StringBuilder Dim i As Long For i = 0 To ELM(This.list.Count()) string.Append(This.list.Item[i]).Append(Ex"\r\n") Next Return string.ToString End Function End Class End Namespace End Namespace End Namespace