I’m not sure how to make the question clearer but this is bascially the problem:
I have a class that is dervived from another one of my classes.
The base class has an overridden Tostring function (returns 2 strings separated by a colon).
The problem is that my derived class can have an array of strings or just the one string so when I override the ToString function I need to return the base class as well as the array of strings (separated by “\n”) in the derived class. Now I’m wondering what would be the best way to do this; should I return an array of strings( if possible) or do I have no choice but to use the Stringbuilder class? If there’s another way to do this please tell.. All ideas welcomed no matter how crazy they may be 🙂
When overriding
ToStringyou have to return just a string. You can’t return any other type. It sounds like you might want something like this:That’s assuming you want to return a string such as:
where the line separators are
\n.