VB.net Program to Demonstrate the Clear() Method of Array Class

You are currently viewing VB.net Program to Demonstrate the Clear() Method of Array Class

VB.Net program to demonstrate the Clear() method of Array class

'VB.NET program to demonstrate the Clear() 
'method of Array class.

Imports System

Module Module1
    Sub Main()
        Dim arr() As Integer = {10, 20, 30, 40, 50}

        'Reset item in the array from index 2 to 3 by 0.
        Array.Clear(arr, 2, 2)

        Console.WriteLine("Array elements:")
        For i = 0 To arr.Length - 1 Step 1
            Console.Write(arr(i) & " ")
        Next
        Console.WriteLine()
    End Sub
End Module
Array elements:
10 20 0 0 50
Press any key to continue . . .

Ranjith Kumar

Hi, I'm Ranjith a full-time Blogger, YouTuber, Affiliate Marketer, & founder of Coding Diksha. Here, I post about programming to help developers.

Leave a Reply