D
dorminey
I am having a problem where a few machines at my company are failing on
the following line of code:
double dbl = System.Convert.ToDouble("0");
I have traced it to the fact that for the thread's current culture
("en-US") the NumberFormat.PositiveSign is in fact set to "0" instead
of "+".
In .net 1.1 there was a culture.nlp file where this info was stored but
it has changed in 2.0. Where is this "0" for PositiveSign coming from
and why is it defaulted to zero on a small minority of boxes at my
workplace? Below is a sample program that explains all. Thanks to
anyone who can help.
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Globalization;
namespace ConsoleApplication10
{
class Program
{
static void Main(string[] args)
{
//this line fails on several machines at LockHeed
//it will work on most machines on which it is run
double dbl = Convert.ToDouble("0");
//here we can reproduce the error we see on the problem
machines
CultureInfo ci = new
System.Globalization.CultureInfo("en-US");
ci.NumberFormat.PositiveSign = "0";
Thread.CurrentThread.CurrentCulture = ci;
dbl = Convert.ToDouble("0");
//The problem we are seeing is that on the problem machines
//the PositiveSign property is "0" by default instead of
the
//proper value of "+". The culture on these boxes is
"en-US".
}
}
}
the following line of code:
double dbl = System.Convert.ToDouble("0");
I have traced it to the fact that for the thread's current culture
("en-US") the NumberFormat.PositiveSign is in fact set to "0" instead
of "+".
In .net 1.1 there was a culture.nlp file where this info was stored but
it has changed in 2.0. Where is this "0" for PositiveSign coming from
and why is it defaulted to zero on a small minority of boxes at my
workplace? Below is a sample program that explains all. Thanks to
anyone who can help.
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading;
using System.Globalization;
namespace ConsoleApplication10
{
class Program
{
static void Main(string[] args)
{
//this line fails on several machines at LockHeed
//it will work on most machines on which it is run
double dbl = Convert.ToDouble("0");
//here we can reproduce the error we see on the problem
machines
CultureInfo ci = new
System.Globalization.CultureInfo("en-US");
ci.NumberFormat.PositiveSign = "0";
Thread.CurrentThread.CurrentCulture = ci;
dbl = Convert.ToDouble("0");
//The problem we are seeing is that on the problem machines
//the PositiveSign property is "0" by default instead of
the
//proper value of "+". The culture on these boxes is
"en-US".
}
}
}