Reputation: 1305
I have an array and a loop, I want to find the current item's index so that I can decide whether to show that item in a listbox or not,
string[] papers = new string[7] { "Software Development", "Data Fundamentals", "Information and Communication", "User Support", "Web Fundamentals", "Network Fundamentals", "Computer Fundamentals" };
for (int i = 0; i < papers.Length; i++)
{
int n=papers.Length;
if (n==2)
{
continue;
}
else
{
listView1.Items.Add(papers[i]);
}
}
But I am unable to achieve it, could some one help me please... Or is there a better way to do this??
Thank you
Upvotes: 2
Views: 2533
Reputation: 4754
The variable i
is your current index.
for (int i = 0; i < papers.Length; i++)
{
if (i==2)
continue;
else
listView1.Items.Add(papers[i]);
}
Upvotes: 6