get index of item in listbox c#
c#
Solution
Why not use a for loop?
for (int i = 0; i < lstCostCenter.Items.Count; i++)
{
ListItem lstItem = lstCostCenter.Items[i];
}
The index of the current item is `i`.
Problem
I am trying to get index of each items in a listbox Here is my code ``` foreach (ListItem lstItem in lstCostCenter.Items) { int x = lstCostCenter.Items.IndexOf(lstItem); } ``` But each time its returning 0 only. Please some one help me. Thanks Gulrej