No overload for method 'ToString' takes '1' arguments: YES IT DOES!

This tiny code just updates my gui with the correct ingame time. It compiles in Visual C# but Unity says that ToString doesn't have anything that takes only 1 argument when obviously it does! What's the deal here?

private void UpdateTime()
{
    time = TimeControl.CurrentTime.ToString("hh:mm tt");
}

Ehm, I think the problem starts with that TimeControl isn't in the scripting reference. What library are you using?

You might have to show us the TimeControl script. Its hard to tell without it.

Have you tried passing different parameters? I'm honestly not familiar with them but I use the "f[0-9]" so it definitly can take one(1) argument.

2 Answers

2

The overload of TimeSpan.ToString that takes a format string as an argument was not added until .NET 4.0. Unity's current version of Mono is effectively .NET 3.5.

Since wildboy didn't bother to post his solution here, check out this one: http://answers.unity3d.com/questions/259482/format-string-minutesseconds.html

Have you overridden ToString in your TimeControl class? "hh:mm tt" isn't any kind of standard string format.