问题描述:

How to make an int variable show as currency in console app. Begin with EGP. I tried the following code, but it only shows the Arabic as ".", not EGP.

 double x = 12.5;

Console.WriteLine(x.ToString("C",CultureInfo.CreateSpecificCulture("ar-EG")));

But the result is: ?.?.? 12.5 instead of "EGP" because it is in Arabic language. What I need is to make it EGP 12.5 not "."

网友答案:

EGP is the ISOCurrencySymbol for Egyptian Pound.

This should work for you.

using System;
using System.Globalization;
public class PrintCurrencyValue  {
   public static void Main()  {
      double x = 12.5;
      RegionInfo myRI1 = new RegionInfo( "ar-EG" );
      Console.WriteLine( "CurrencySymbol:    {0} {1:N}", myRI1.CurrencySymbol, x);
      Console.WriteLine( "ISOCurrencySymbol: {0} {1:N}", myRI1.ISOCurrencySymbol, x);
   }
}
相关阅读:
Top