How to update only one element by index in a list of numbers with VB.NET

1 Answer

0 votes
Imports System
Imports System.Collections.Generic

Public Class Program
	Public Shared Sub Main()
        Dim list As List(Of Integer) = New List(Of Integer) From {
            3,
            7,
            8,
            91,
            99,
            10,
            -5,
            1,
            2
        }
		
        Dim indexToUpdate As Integer = 2
        Dim newValue As Integer = 8497
		
        list(indexToUpdate) = newValue
		
        Console.WriteLine(String.Join(", ", list))
    End Sub
End Class



' run:
'
' 3, 7, 8497, 91, 99, 10, -5, 1, 2
'

 



answered Oct 18, 2023 by avibootz
...