本文介绍了小数点后的值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将此字符串格式"String.Format("{0:0.00}", mytextbox.Text);"应用于我的mytextbox

但我也希望它包括以下课程

I want to apply this string format "String.Format("{0:0.00}", mytextbox.Text);" to my mytextbox

But I also want it to include following class

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;
  }
}



但是问题是我不知道在哪里写字符串格式或如何写.
简而言之困惑.
帮帮我.



But the issue is I don''t know where to write string format or how.
Inshort confused.
Help me.

推荐答案



这篇关于小数点后的值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-29 08:05