Assuming MustHaveString
looks something like:
public void MustHaveString(string arg)
Then simply saying thing
results in a compile error, unless thing
has an implicit conversion to string
. Without the implicit conversion, you must do thing.ToString()
. If, however, your code is like:
string myString = "This is a thing: " + thing;
Then the ToString
is implicitly called, so it's optional.
In most cases, I would recommend explicitly calling the ToString
method, to make it clear to people reading your code what's going on.
Edit: since this answer was accepted, I thought I should also mention that you should make your ToString()
method an override
, not a new
. This will result in the normally-expected behavior, which is what I described above.