
WriteLine( "List2 Elements Count: " & lst2.Count)Ĭonsole. WriteLine( "List1 Capacity: " & lst.Capacity)Ĭonsole. WriteLine( "List1 Elements Count: " & lst.Count)Ĭonsole. Visual Basic Generic List (List(Of T)) Exampleįollowing is the example of using the generic list ( List(Of T)) in visual basic programming language.ĭim lst As List ( Of Integer) = New List ( Of Integer)()ĭim lst2 As List ( Of String) = New List ( Of String)()Ĭonsole. It will copies the elements of List to new array object. It is used to remove a range of elements from the List. It is used to remove an element from the list based on the specified index position. It is used to remove the first occurrence of specified element from the List.

It is used to insert all the elements of specified collection into List starting from the specified index.

It is used to insert an element into the list at the specified index. It is used to iterate through the List to access elements. It is used to retrieve all the elements that matches the conditions defined by the specified predicate. It is used to search for an element that matches the conditions defined by the specified predicate and returns the first occurrence of the List. It is used to copy entire List to a compatible one-dimensional array. It is used to determine whether the specified element exists in the List or not. It will remove all the elements from the List. It is used to add all the elements of specified collection at the end of the List. It is used to add an element at the end of the List. It is used get or set an element at the specified index.įollowing are the some of commonly used methods of generic list to perform add, search, insert, delete or sort operations in a visual basic programming language. It is used to get the number of elements in list. It is used to get or set the number of elements a list can contain. The following are some of the commonly used properties of the generic list in a visual basic programming language.

If you observe the above example, we defined a list ( lst) with String data type to store only string elements. Dim lst As List( Of String) = New List( Of String)()
