What is wrong with my code? Here is my code:
public override string ToString()
{
return String.Format("Number : {0} \nFloors:{1} \nStreet \n{ \nName : {2},\nLength : {3}\n}",Number,Floors,Street.Name,Street.Length);
}
You need to escape your curly brackets:
"Number : {0} \nFloors:{1} \nStreet \n{{ \nName : {2},\nLength : {3}\n}}"
If you need {
or }
in the resulting string, you need to escape them as {{
and }}
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With