[Mono-list] CultureInfo.InvariantCulture.Clone()
Fredrik Ålund
fredrik.alund@mimer.se
Tue, 19 Oct 2004 10:24:30 +0200
I have problems getting my application that is developed for .NET
Framework 1.1 to work with Mono. The problem is that
CultureInfo.InvariantCulture.Clone() gives me a clone where NumberFormat
and DateTimeFormat is read only. This is not the case on Microsoft .NET
Framework 1.1. An example that tests for read-only follows. On MS .NET
Framework 1.1 both the NumberFormat and DataTimeFormat are read-write but
on Mono they are read-only.
using System;
using System.Globalization;
namespace CloneTest
{
class CloneTest
{
[STAThread]
static void Main(string[] args)
{
CultureInfo myCultureInfo = (CultureInfo)
CultureInfo.InvariantCulture.Clone();
if(myCultureInfo.IsReadOnly)
{
Console.WriteLine("Wrong: Culture Read-Only");
}
else
{
Console.WriteLine("Ok: Culture Read-Write");
}
//DateTimeFormat
if(myCultureInfo.DateTimeFormat.IsReadOnly)
{
Console.WriteLine("Wrong: myCultureInfo.DataTimeFormat is read-only");
}
else
{
Console.WriteLine("Ok: myCultureInfo.DataTimeFormat is read-write");
}
//NumberFormat
if(myCultureInfo.NumberFormat.IsReadOnly)
{
Console.WriteLine("Wrong: myCultureInfo.NumberFormat is read-only");
}
else
{
Console.WriteLine("Ok: myCultureInfo.NumberFormat is read-write");
}
//Throws an exception on Mono saying that myCultureInfo is read-only.
//myCultureInfo.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd";
//The following sequence work on Mono
myCultureInfo.DateTimeFormat= new DateTimeFormatInfo();
myCultureInfo.DateTimeFormat.ShortDatePattern = "yyyy-MM-dd";
}
}
}
Am I missing something or is this an error in Mono, or is it an error in
MS .NET Framework 1.1?
Regards,
Fredrik