- Home /
Question by
dsillman2000 · Feb 23, 2014 at 09:50 PM ·
timelabelseconds
Time by the second?
Hey, my current code to display time in a label is:
"\n Time elapsed: "+Time.time
However, this displays the time in like nanoseconds. I would like it to display only to the tenth place, like 10.5 instead of 10.51826. Any help would be appreciated.
Comment
This is from the first Google hit for "C# format float". There are a variety of other ways to format strings.
"\n Time elapsed: "+Time.time.ToString("0.0");
yourFloat = $$anonymous$$athf.Round(yourFloat * 100f) / 100f;
Answer by getyour411 · Feb 23, 2014 at 10:12 PM
Please Google 'format float' for whatever language you use, and review any of the many many examples out there.
Sorry, I don't really understand them. I'm new to C#. None of them really seem to fix the problem anyway.