I want to get a string (str) by using below statements, it works but any suggestions to formulate this control?
because count can be “n”.
if (a.count== 0)
{
str += a.Name;
}
else if (a.count== 1)
{
str += a.Parent.Name + "/" + a.Name;
}
else if (a.count== 2)
{
str += a.Parent.Parent.Name + "/" + a.Parent.Name + "/" + a.Name;
}
else if (a.count== 3)
{
str += a.Parent.Parent.Parent.Name + "/" +a.Parent.Parent.Name + "/" + a.Parent.Name + "/" + a.Name;
}
.
.
.
else if(a.count = n)
{
//n times..
}
Something like the following (but you’ll need to play with it to make it work):
There’re obviously a lot of corner cases, which you need to take into account.