How to populate a ListBox Control with an Array of Strings in C# and vb.net

List box control contains list of items and we can select one or more items from the listbox.
following example adds an array of strings to a ListBox control.

Example

this example requires Windiws form that contains Listbox control named Listbox1.
following methods bind Listbox with the listbox items from Array of strings.

[VB.Net]

  Private Sub BindListBox()
        Dim ArrTempList As String() = New String(4) {}
 
        ArrTempList(0) = "Delhi"
        ArrTempList(1) = "Newyork"
        ArrTempList(2) = "Tokyo"
        ArrTempList(3) = "Paris"
        ArrTempList(4) = "London"
 
        ListBox1.Items.AddRange(ArrTempList)
    End Sub

[C#]

private void BindListBox()
{
	string[] ArrTempList = new string[5];
 
	ArrTempList[0] = "Delhi";
	ArrTempList[1] = "Newyork";
	ArrTempList[2] = "Tokyo";
	ArrTempList[3] = "Paris";
	ArrTempList[4] = "London";
 
	ListBox1.Items.AddRange(ArrTempList);
}