Every once in a while I am doing something in programming that is….well, simply annoying.  I came across one of these tonight while doing a little work.

Lets say I have a number (double) which is a percent and I want to display it somehow.

Double percent = .1234;
String display = percent.ToString(“P2”);

Simple enough, nothing to worry about; now take that same string and turn back into a double.  Basically you can’t, you need to create a special function that will go and strip the % (if it exists) and then divide the resulting number by 100.  Now this is a small thing, but it annoys the crap out of me.  Microsoft has taken the time to handle currency, negatives, thousand separators and most any other type of string based number, why not a percentage?

http://potterspages.blogspot.com/2008/02/convert-percent-string-to-double.html

Advertisements