I'm trying to figure out how to populate this if statement dynamically so that I dont have to continue adding else if's to it when I add more items to the list. I'm sure I could do it with nested foreach statements, I just not sure how to do it properly.
private List<string> uriList = new List<string>();
private List<string> titleList = new List<string>();
if (item.Text == titleList[0])
{
YTPlayer(uriList[0].ToString());
}
else if (item.Text == titleList[1])
{
YTPlayer(uriList[1].ToString());
}
else if (item.Text == titleList[2])
{
YTPlayer(uriList[2].ToString());
}
else
{
}
Aucun commentaire:
Enregistrer un commentaire