469,117 Members | 1,342 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,117 developers. It's quick & easy.

Convert.ToDouble problem

does anybody know how to change the global IFormatProvider of my project so
everycall to Convert.ToDouble on it uses this format provider instead of the
one the one on the computer's regional configuration
Sep 26 '05 #1
4 3319
Hi Irepan,

Convert.ToDouble uses the NumberFormatInfo of the CurrentCulture. If you change this CultureInfo you won't have to specify a IFormatProvider for eavh Convert.
On Mon, 26 Sep 2005 21:00:01 +0200, Irepan <Ir****@discussions.microsoft.com> wrote:
does anybody know how to change the global IFormatProvider of my project so
everycall to Convert.ToDouble on it uses this format provider instead of the
one the one on the computer's regional configuration


--
Happy coding!
Morten Wennevik [C# MVP]
Sep 27 '05 #2
Irepan,
does anybody know how to change the global IFormatProvider of my project
so
everycall to Convert.ToDouble on it uses this format provider instead of
the
one the one on the computer's regional configuration


Can you tell us to learn, why you want to do this?

Cor
Sep 27 '05 #3
sure i can, as a matter of fact i find an easy solution for this using
Thread.CurrentThread.CurrentCulture = new CultureInfo(blabla) but i need it
for PDA and CurrentCulture doesn't exists on CurrentThread's properties for
Compact framework, but anyway, the problem that i have is that when i
programmed my PDA application i used Convert.ToDouble(aString) to convert the
strings i get from the GPS to know a location so usually if i have a string
"134.523453" my double value will be 134.523453 that worked fine and i have
this kind of conversion all over my application's source, the problem is when
i use a PDA with a different Region information for instance spanish
(international) which have the decimal point set to a colon "," and the
separators as points "." then at those PDA's the function will get me a value
of 134523453 instead of the 134.523453 that i need.

"Cor Ligthert [MVP]" wrote:
Irepan,
does anybody know how to change the global IFormatProvider of my project
so
everycall to Convert.ToDouble on it uses this format provider instead of
the
one the one on the computer's regional configuration


Can you tell us to learn, why you want to do this?

Cor

Sep 28 '05 #4
Irepan,

If I resume, the GPS is giving you a string in the English language style
setting and because that the culture setting in your system is in the style
of most other languages it will be wrong converted.

Interesting problem.

Maybe can you use this one. It is supported by the CompactFramework and
seems for me for your problem.

http://msdn.microsoft.com/library/de...lturetopic.asp

I hope this helps,

Cor

"Irepan" <Ir****@discussions.microsoft.com> schreef in bericht
news:B5**********************************@microsof t.com...
sure i can, as a matter of fact i find an easy solution for this using
Thread.CurrentThread.CurrentCulture = new CultureInfo(blabla) but i need
it
for PDA and CurrentCulture doesn't exists on CurrentThread's properties
for
Compact framework, but anyway, the problem that i have is that when i
programmed my PDA application i used Convert.ToDouble(aString) to convert
the
strings i get from the GPS to know a location so usually if i have a
string
"134.523453" my double value will be 134.523453 that worked fine and i
have
this kind of conversion all over my application's source, the problem is
when
i use a PDA with a different Region information for instance spanish
(international) which have the decimal point set to a colon "," and the
separators as points "." then at those PDA's the function will get me a
value
of 134523453 instead of the 134.523453 that i need.

"Cor Ligthert [MVP]" wrote:
Irepan,
> does anybody know how to change the global IFormatProvider of my
> project
> so
> everycall to Convert.ToDouble on it uses this format provider instead
> of
> the
> one the one on the computer's regional configuration


Can you tell us to learn, why you want to do this?

Cor

Sep 28 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by cindy liu | last post: by
10 posts views Thread by | last post: by
3 posts views Thread by user | last post: by
2 posts views Thread by Jason | last post: by
4 posts views Thread by Irepan | last post: by
3 posts views Thread by mrajanikrishna | last post: by
4 posts views Thread by Yoavo | last post: by
1 post views Thread by CARIGAR | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.