x


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");
}
more ▼

asked Apr 24 '11 at 04:24 PM

WildBamaBoy gravatar image

WildBamaBoy
3 1 1 4

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

Apr 24 '11 at 04:31 PM Joshua

TimeControl is a class of my own, attached to my main camera.

Apr 24 '11 at 04:38 PM WildBamaBoy

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

Apr 24 '11 at 05:26 PM Casper 1

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.

Apr 24 '11 at 05:55 PM by0log1c
Apr 24 '11 at 07:42 PM WildBamaBoy
(comments are locked)
10|3000 characters needed characters left

2 answers: sort oldest

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.

more ▼

answered Apr 24 '11 at 08:00 PM

Bampf gravatar image

Bampf
5.1k 8 20 49

Crap! How can I format it correctly then?

Apr 24 '11 at 10:20 PM WildBamaBoy

Solved----------

Apr 25 '11 at 12:54 AM WildBamaBoy

Can you share with other people that stumble across this thread?

Jun 15 '11 at 04:16 AM vxssmatty
(comments are locked)
10|3000 characters needed characters left

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

more ▼

answered Apr 24 '11 at 07:36 PM

Eric5h5 gravatar image

Eric5h5
81.5k 42 133 529

Okay maybe I'm just doing the formatting the wrong way...

"CurrentTime = new TimeSpan(Hour, Minute, 0);" Is all that it really does. I want it to show time like "03:25 AM", I don't want seconds on there, so I tried that format...How can I do it right?

Apr 24 '11 at 07:45 PM WildBamaBoy
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x199
x20
x18
x16

asked: Apr 24 '11 at 04:24 PM

Seen: 3025 times

Last Updated: Jun 15 '11 at 04:16 AM