public override string ToString()
{
string token = "something";
foreach (something item in this)
{
something = something + "Some_Point({0},{1}),";
string.Format(something, item.X, item.Y);
}
return something+= "anything";
}
This is the overridden ToString()
method of a custom collection. The problem here is that String.Format
isn't substituting the values of X and Y. It does substitute whenever I add return before String.Format
. I am just starting to learn C# and have no idea what is causing this strange behaviour.
string.Format
returns formatted string, you have to assign it back to your variable:
something = string.Format("Some_Point({0},{1}),", item.X, item.Y);