I:
Ii. Code
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; // define the double type variable if (double. tryParse (txt_str.Text, Out P_dbl_temp) // verify that the input is correct and assign a value {// Globalization, ystem. the Globalization namespace contains a class that defines information related to the region, including the language, country/region, // calendar in use, date, currency, and Number Format mode, and the sort order of strings. System. Globalization. NumberFormatInfo GN = // instantiate the NumberFormatInfo object. NumberFormatInfo provides specific regional information for formatting and Analysis of numeric values. New System. globalization. cultureInfo ("zh-CN", false ). numberFormat; // CultureInfo ("zh-CN", false) is based on the region specified by the name and based on the Boolean value (whether to use the locale selected by the user in the System) to initialize a new instance of the CultureInfo class // NumberFormat to obtain or set NumberFormatInfo, which defines the format GN that is applicable to the culture, displays numbers, currencies, and percentages. currencyGroupSeparator = ","; // gets or sets a string that groups the digits on the left of the decimal point in the currency value. Txt_result.Text = P_dbl_temp.ToString ("C", GN); // format and display the format as currency. Currency 2.5.ToString ("C") ¥ 2. 50} else {MessageBox. show ("enter the correct currency value! "," Prompt! "); // Output error message }}}}