zoukankan      html  css  js  c++  java
  • 格式化为货币

    一:截图

    二:代码

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    
    namespace Format
    {
        public partial class Frm_Main : Form
        {
            public Frm_Main()
            {
                InitializeComponent();
            }
    
            private void btn_Set_Click(object sender, EventArgs e)
            {
                double P_dbl_temp;//定义double类型变量
                if (double.TryParse(txt_str.Text, out P_dbl_temp))//验证输入是否正确并赋值
                {
                    //Globalization,ystem.Globalization 命名空间包含定义区域性相关信息的类,这些信息包括语言,国家/地区,
                    //正在使用的日历,日期、货币和数字的格式模式,以及字符串的排序顺序。
                    System.Globalization.NumberFormatInfo GN =//实例化NumberFormatInfo对象,NumberFormatInfo提供用于对数字值进行格式设置和分析的区域性特定信息。
                        new System.Globalization.
                            CultureInfo("zh-CN", false).NumberFormat;// CultureInfo("zh-CN", false)基于名称指定的区域性并基于布尔值(指定是否使用系统中用户选定的区域性设置)来初始化 CultureInfo 类的新实例
                    //NumberFormat获取或设置 NumberFormatInfo,它定义适合区域性的、显示数字、货币和百分比的格式
                    GN.CurrencyGroupSeparator = ",";//获取或设置在货币值中对小数点左边数字进行分组的字符串。
                    txt_result.Text = P_dbl_temp.ToString("C", GN);//格式化为货币格式并显示, 货币 2.5.ToString("C") ¥2.50  
                }
                else
                {
                    MessageBox.Show("请输入正确的货币值!","提示!");//输出错误信息
                }
            }
        }
    }
  • 相关阅读:
    TensorFlow object detection API
    bounding box的简单理解
    OverFeat学习
    tensorflow调试tfdbg
    2018.7-2019.4记录
    人工智能未来读后感 ----by RayKurzweil
    matlab exe
    神经网络的基础
    研究生的论文
    卷积神经网络经验
  • 原文地址:https://www.cnblogs.com/hongmaju/p/3763099.html
Copyright © 2011-2022 走看看