2011-01-14 5 views
1

私のアプリケーションのNumberDecimalSeparatorを "。"から変更したい"/"にします。私はテキストボックスに浮動小数点数を表示するときに動作します。整数型はまったく表示されません。C#CultureInfo NumberFormat NumberDecimalSeparator問題

スレッドのカルチャを変更して、アプリケーション全体の書式設定を取得します。私のコードは次のようである:

CultureInfo ci = new CultureInfo("fa-IR", true); 
ci.NumberFormat.DigitSubstitution = DigitShapes.NativeNational; 
ci.NumberFormat.NumberDecimalSeparator = "/"; 
Thread.CurrentThread.CurrentCulture = ci; 

結果:

3.14 => "3/14" 100 => ""

任意のヘルプしてください?

答えて

2

私はちょうどこのようなテストコンソールアプリケーションを作成しますが、このような出力を持っている:

Input next value: 
3.14 
3/14 
Input next value: 
100 
100 

私のコードだった:

using System; 
using System.Globalization; 
using System.Threading; 

namespace ConsoleApplication1 
{ 
    class Program 
    { 
     static void Main(string[] args) 
     { 
      CultureInfo ci = new CultureInfo("en-US", true);    
      Thread.CurrentThread.CurrentCulture = ci; 
      Console.WriteLine("Input next value:"); 
      string input = Console.ReadLine(); 

      while (input != "e") 
      { 
       double dblInput = double.Parse(input); 
       CultureInfo ci2 = new CultureInfo("fa-IR", true); 
       ci2.NumberFormat.DigitSubstitution = DigitShapes.NativeNational; 
       ci2.NumberFormat.NumberDecimalSeparator = "/"; 
       Thread.CurrentThread.CurrentCulture = ci2; 

       Console.WriteLine(dblInput); 
       Console.WriteLine("Input next value:"); 
       input = Console.ReadLine(); 
      } 
     } 
    } 
} 

ここにあなたの質問にapplicabaleない何かか?