C# Loop thru a Listbox

Just started knocking around in C#.

For the life of me (no pun intended)....I cannot convert this from VB:

for i = 0 to List1.listcount - 1

MsgBox (List1.List(i))

next

Believe me.....I have tried every logical possibility....this is pretty scary, from what I've read the syntax diffs between VB.Net/VB and C#....are not really that different.

for (int i = 0; i < 5; i++)

MessageBox.Show(listbox1.?

[467 byte] By [cablehead] at [2007-12-17]
# 1



for (int i = 0; i < listBox1.Items.Count; i++)
{
MessageBox.Show(listBox1.Items[ i ].ToString());
}

DanielRieck at 2007-9-9 > top of Msdn Tech,Visual Studio Express Editions,Installing and Registering Visual Studio 2005 Express Editions...
# 2
Thanks Dan.

Those brackets almost drove me crazy.

So...from what I have gleaned....

A listbox is..array-ish..?.....hence the brackets Idea...?

cablehead at 2007-9-9 > top of Msdn Tech,Visual Studio Express Editions,Installing and Registering Visual Studio 2005 Express Editions...
# 3
Hi,

listbox.items is an array thet contains the Objects stored in a listbox. In C# you access a listbox with those brackets []. Not the listbox is an array only some properties of it are.

rgerbig at 2007-9-9 > top of Msdn Tech,Visual Studio Express Editions,Installing and Registering Visual Studio 2005 Express Editions...