List.Item Property In VB.NET

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

Item

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)

        Console.WriteLine(auth)

        ' Set first item of a List

        AuthorList(0) = "New Author"

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

        Console.ReadLine()

    End Sub

End Module

Output:

Item-property-of-list-in-vb.net.jpg

Categories

More Articles

© 2020 DotNetHeaven. All rights reserved.