Let's say I have a number (e.g. double) and transform it using some format string into a string variable :
var str = string.Format("{0:0%}", 0.256);
(the content of the str variable is in this case "26%"
). Is there any way to parse this string back into the number ?
I'm aware that depending on the format string the lossless conversion back might not be possible - just as in this case 0.26
is the best I can get because some information (3rd decimal place) was simply lost in the formatting. But even getting 0.26
from a combination of the format string "{0:0%}"
and the string 26%
would be great if it's possible in some automatic way.