I have a class named Myclass with an override of ToString() like this:
class Field
{
}
class MyClass
{
Field propretie1
Field propretie2
.
.
.
Field propretie15
public override string ToString()
{
StringBuilder temp = new StringBuilder();
temp.Append(propretie1.ToString())
temp.Append("|");
temp.Append(propretie2.ToString())
temp.Append("|");
.
.
temp.Append(propretie15.ToString())
return temp.ToString();
}
}
I'd like to know if there is a better way to get over all the properties of Myclass with the declaration order to implement the ToString function.
No, there is no way to do this by your requirements other than coding each function manually. It would be easy with reflection, but
So there is no way to actually get the order of the declaration. You could try alphabetical order by ordering them yourself though.