In a foor loop I need to create an item depending on an obj value:
for example:
for(int i=0;i<mylist.count;i++)
if(mylist[i].type==1)
{
//create radiobutton
}
else if(mylist[i].type==2)
{
//create ratingview
}
and so on
If more than one radiobutton is created in C#, how can I differentiate between the radiobuttons and the ratingviews? Like how can I put a tag or id for each item is created?
Solution:
If you can't find a tag property, just create one:
public void test() {
for (int i = 0; i < 10; i++)
if (i<5)
{
//create radiobutton
radiobutton btn = new radiobutton
{
Text = "Click to Rotate Text!",
VerticalOptions = LayoutOptions.CenterAndExpand,
HorizontalOptions = LayoutOptions.Center,
tag = i
};
Console.WriteLine(btn.tag);
}
else if (i > 2)
{
//create ratingview
}
}
public class radiobutton : Button
{
public int tag;
}