Frage

I just want to make sure that at a minimum my digits are displaying with 2. So 1 should display as 01.

I need this for time display XX:XX.XX

Formats I have tried but all of them seem to throw an error "D2", "D5", "00" (Custom )

        display_T35.SimpleGraphics.DisplayText(
            String.Concat(timeParts.Minutes.ToString(), 
                          ":",
                          timeParts.Seconds.ToString(),
                          ".",
                          timeParts.Milliseconds.ToString()),
            font,
            color,
            TimerCoordinates.X,
            TimerCoordinates.Y
            );

Minutes, Seconds and Milliseconds are uint.

I just get a Exception for any of them:

An unhandled exception of type 'System.ArgumentException' occured in mscorlib

I am not sure if the format string is supported but it is showing it to me through intellisense.

Thoughts?

Thanks

War es hilfreich?

Lösung

Please be specific in your question. You do not show us the type of timeParts. I'm going to assume that the Minutes, Seconds, and Milliseconds properties are Int32.

The documentation for the .Net Micro Framework is available on MSDN here. If you drill down into the methods for System.Int32 you will see a very limited version of the formats the ToString() method accepts.

There seems to be an open source project, .Net Micro Framework Common Extensions, which implements some of the string manipulation features of the full .Net framework. They might have what you need, or you could write your own specific formatter.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top