List.Item Property In VB.NET

In this article I describe about List.Item property in VB.NET.
  • 3701


The Item property gets and sets the value associated with the specified index.
The following code snippet gets and sets the first item in a list.

Imports System.Text

Imports System.IO

Imports System.Collections.Generic

Module Module1

    Sub Main()

       ' Create a list of strings

        Dim AuthorList As New List(Of String)()

        AuthorList.Add("Mahesh Chand")

        AuthorList.Add("Praveen Kumar")

        AuthorList.Add("Raj Kumar")

        AuthorList.Add("Nipun Tomar")

        AuthorList.Add("Dinesh Beniwal")

        ' Get first item of a List

        Dim auth As String = AuthorList(0)


        ' Set first item of a List

        AuthorList(0) = "New Author"

        Console.WriteLine("Updated Author:{0}", AuthorList(0))


    End Sub

End Module



More Articles

© 2020 DotNetHeaven. All rights reserved.