无法在我的C#项目上获得EUR符号货币,我得到了“?"字样. ; [英] Can NOT get the EUR symbol currency on my C#projects , i get a "?" ;

查看:56
本文介绍了无法在我的C#项目上获得EUR符号货币,我得到了“?"字样. ;的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我测试过的代码:

  类Program1
    {


      静态void Main(string [] args)
       {
       int i = 100;
       //将CurrentCulture设置为葡萄牙语
       CultureInfo myCI = new CultureInfo("pt-PT",false);
       //克隆myCI并修改与该克隆关联的DTFI和NFI实例.
       CultureInfo myCIclone =(CultureInfo)myCI.Clone();
       myCIclone.NumberFormat.CurrencySymbol ="EUR";
      //显示与原始副本和克隆副本关联的DTFI和NFI实例的属性.
        Console.WriteLine("NFI.CurrencySymbol \ t {0} \ t \ t {1}",myCI.NumberFormat.CurrencySymbol,myCIclone.NumberFormat.CurrencySymbol);
      
       Console.WriteLine("{0:C}",i);  //用货币符号打印!!!! ?

       Thread.CurrentThread.CurrentCulture =新的CultureInfo("pt-PT");

       Console.WriteLine("{0:C}",i);  //用货币符号打印!!!! ?

       Thread.CurrentThread.CurrentCulture = new CultureInfo("pt-PT",false);
       Console.WriteLine("{0:C}",i);  //用货币符号打印!!!! ?



       //另一个测试
       RegionInfo myRI1 = new RegionInfo("PT");
       Console.WriteLine(   ISOCurrencySymbol:        Console.WriteLine("CurrencySymbol:","nbsp" {1},{0} ;
       Console.ReadLine();
       }

    class Program1
    {


        static void Main(string[] args)
        {
        int i = 100;
        // Sets the CurrentCulture to Portuguese
        CultureInfo myCI = new CultureInfo("pt-PT", false);
        // Clones myCI and modifies the DTFI and NFI instances associated with the clone.
        CultureInfo myCIclone = (CultureInfo)myCI.Clone();
        myCIclone.NumberFormat.CurrencySymbol = "EUR";
       // Displays the properties of the DTFI and NFI instances associated with the original and with the clone.
         Console.WriteLine("NFI.CurrencySymbol\t{0}\t\t{1}", myCI.NumberFormat.CurrencySymbol, myCIclone.NumberFormat.CurrencySymbol);
       
        Console.WriteLine("{0:C}", i);  // print with currency symbol !!!! ?

        Thread.CurrentThread.CurrentCulture = new CultureInfo("pt-PT");

        Console.WriteLine("{0:C}", i);  // print with currency symbol !!!! ?

        Thread.CurrentThread.CurrentCulture = new CultureInfo("pt-PT",false);
        Console.WriteLine("{0:C}", i);  // print with currency symbol !!!! ?



        // another test
        RegionInfo myRI1 = new RegionInfo("PT");
        Console.WriteLine("   ISOCurrencySymbol:            {0}", myRI1.ISOCurrencySymbol);
        Console.WriteLine("   CurrencySymbol:               {0}", myRI1.CurrencySymbol);
        Console.ReadLine();
        }

//   下面的控制台结果

//    THE RESULT on CONSOLE below

   }

    }

推荐答案

Yuour .Net代码获得Unicode格式的CurrencySymbol,但很可能您的控制台未配置为接受Unicode字符.您可以尝试以下方法:

Yuour .Net code obtains the CurrencySymbol in Unicode, but most likely your console is not configured to accept Unicode characters. You can try this:

Console.OutputEncoding = System.Text.Encoding.Unicode

Console.OutputEncoding = System.Text.Encoding.Unicode

https://msdn.microsoft.com/zh-cn/library/system.console.outputencoding(v = vs.110).aspx


这篇关于无法在我的C#项目上获得EUR符号货币,我得到了“?"字样. ;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆