What is Array in ASP.NET?

Array:

Arrays are using for store similar data types grouping as a single unit. An array is whose size can increase and decrease dynamically. It has the following syntax:

Dim str(2) As String
str(0) = "Sunday"
str(1) = "Monday"

Example:

Partial Class _Default
	Inherits System.Web.UI.Page

	Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

		Dim str(6) As String
str(0) = "Sunday"
str(1) = "Monday"
str(2) = "Tuesday"
str(3) = "Wednesday"
str(4) = "Thursday"
str(5) = "Friday"
str(6) = "Saturday"
		ListBox1.DataSource = str
		ListBox1.DataBind()

	End Sub
End Class

ArrayList:

Array list can hold item of different types. As Array list can increase and decrease size dynamically you do not have to use the REDIM keyword. You can access any item in array using the INDEX value of the array position.

Example:

Partial Class _Default
	Inherits System.Web.UI.Page

	Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

		Dim strList As New ArrayList
		strList.Add("Sunday")
		strList.Add("Monday")
		strList.Add("Tuesday")
		strList.Add("Wednesday")
		strList.Add("Thurday")
		strList.Add("Friday")
		strList.Add("Saturday")

		ListBox1.DataSource = strList
		ListBox1.DataBind()

	End Sub
End Class