Man kan altid diskutere hvad der er den paeneste loesning.
Jeg ville overveje noget a la:
using System;
using System.Globalization;
namespace E
{
public class MyCultureInfo
{
private static object mylock = new object();
private static MyCultureInfo _instance;
private CultureInfo real;
private MyCultureInfo()
{
real = (CultureInfo)CultureInfo.CurrentCulture.Clone();
real.NumberFormat = (NumberFormatInfo)real.NumberFormat.Clone();
real.NumberFormat.CurrencyDecimalDigits = 0;
real.NumberFormat.CurrencyGroupSeparator = ".";
real.NumberFormat.CurrencyPositivePattern = 1;
real.NumberFormat.CurrencySymbol = ",-";
}
public static CultureInfo Instance
{
get
{
lock(mylock)
{
if(_instance == null)
{
_instance = new MyCultureInfo();
}
return _instance.real;
}
}
}
}
public class Program
{
public static void Main(string[] args)
{
decimal x = 1900.30m;
Console.WriteLine(x.ToString("c"));
Console.WriteLine(x.ToString("c", MyCultureInfo.Instance));
Console.ReadKey();
}
}
}