String.Format("{0:0.00}", mytextbox.Text);
public class DoubleFormatter : IFormatProvider, ICustomFormatter { // always use dot separator for doubles private CultureInfo enUsCulture = CultureInfo.GetCultureInfo("en-US"); public string Format(string format, object arg, IFormatProvider formatProvider) { // format doubles to 2 decimal places return string.Format(enUsCulture, "{0:0.00}", arg); } public object GetFormat(Type formatType) { return (formatType == typeof(ICustomFormatter)) ? this : null; } }
String.Format
DoubleFormatter
Format
null
format
mytextbox.Text
arg
formatProvider
double
Double.TryParse
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)