PC Review


Reply
Thread Tools Rate Thread

Deserialization 1E-08 format

 
 
Serg
Guest
Posts: n/a
 
      15th Dec 2003
Hi. I have a problem with deserialization decimal value.
I have a simple class:

public class A
{
public decimal d;
}

The serialization a value 0.00000001 is OK. The file is

<?xml version="1.0" encoding="utf-8"?>
<A xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<d>1E-08</d>
</A>

If I try to do a deserialization I have an error. But if I
replace by hand
the value of the tag <d> to 0.00000001, I have no error.
How should I work with 1E-08 format?

 
Reply With Quote
 
 
 
 
Tian Min Huang
Guest
Posts: n/a
 
      16th Dec 2003
Hello,

Thanks for your post. I built a sample to check this issue, however, I am
not able to reproduce the problem. It serialize to 0.00000001 (enclosed by
<d> tag) instead of 1E-08. The following is my code, please check it on
your side:

//------------------------code snippet----------------
using System.Xml.Serialization;
using System.IO;

public class A
{
public decimal d;
}

public class Test
{
public static void Main(string[] args)
{
A a = new A();
a.d = 0.00000001m;
XmlSerializer serializer = new XmlSerializer(typeof(A));
TextWriter writer = new StreamWriter("MyDoc.xml");
serializer.Serialize(writer, a);
writer.Close();

TextReader reader = new StreamReader("MyDoc.xml");
A a1 = (A)serializer.Deserialize(reader);
reader.Close();
}
}
//-------------------------end of---------------------------

I look forward to your feedback.

Have a nice day!

Regards,

HuangTM
Microsoft Online Partner Support
MCSE/MCSD

Get Secure! -- www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

 
Reply With Quote
 
Serg
Guest
Posts: n/a
 
      16th Dec 2003
Thank you for your answer. I tried to use your code, but
the result is the same: 1E-08 value. Only d = 0.0001m
serializes to <d>0.0001</d> (it's right), other values are:

0.00001m to 1E-05
0.000001m to 1E-06 etc.

I tried to use this code:

//------------------
CultureInfo ci = new CultureInfo("en-US");
System.Threading.Thread.CurrentThread.CurrentCulture = ci;
//------------------

but it doesn't help me.

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Regarding XML deserialization =?Utf-8?B?RmFpemEgQXNocmFm?= Microsoft Dot NET 0 30th Jan 2007 11:36 AM
Xml deserialization error - Input string was not in a correct format RJN Microsoft VB .NET 0 16th Mar 2006 04:03 PM
XML Deserialization yoshijg Microsoft C# .NET 12 18th Dec 2005 09:47 PM
Deserialization DazedAndConfused Microsoft VB .NET 2 6th Jul 2005 05:56 PM
XML Deserialization Random Microsoft Dot NET Framework 0 27th Jul 2004 12:21 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 07:38 PM.