double.ToString("format") - "System.ArgumentException"

As the title says, when trying to format a double.ToString and also int.ToString() ArgumentExceptions.

I’ve created a thread here:
http://stackoverflow.com/questions/32122402/double-tostringformat-for-netmf-argument-exception

Code

double myDouble = 23.2
string myString = myDouble.ToString("000"); //i've tried other formats
//Expected Result: "023"

Error:

Does anyone have any solutions? (I suppose I could make a custom method, but would rather not)

It’s worth noting that this does NOT happen on the emulator, only when deployed to a device.

Fez Cerb40II NetMF 4.3

The format string is not correct. Check the MF SDK documentation for the Double class in the System namespace.

This is quite bare:
Double.ToString Method (String) | Microsoft Learn <-netmf4 docs don’t show any formatting info

According to this documentation: we can only do “G0” - “G99” / “F0” - “F99” / “N0” - “N99”

Can you provide and example on how to format a double with 3 leading zeros and no decimal places?

@ Gismofx - If the provided formats with MF do not provide what you want, the. you will have to manually do it. cast value to int and the use ToString. check the length of the string and add leading zeroes as required.

converting from double to int you might have to consider rounding.