473,394 Members | 1,739 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Deserialization 1E-08 format

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?

Jul 21 '05 #1
2 2335
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.

Jul 21 '05 #2
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.CurrentCultu re = ci;
//------------------

but it doesn't help me.

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: TEK | last post by:
There seems to be a bug when deserialization some classes in the .NET framework. If you try to deserialize a class that has a base class that holds a struct with a member that is implementing...
3
by: Amadelle | last post by:
Hi all and thanks in advance for your help, I am having problems deserializing an object which seems to be serializing just fine. I save the byte array of the serialized object in the database...
3
by: AnkitAsDeveloper [Ankit] | last post by:
Hi i am serializing a 'ref struct' object as follows : private: void Seri( String ^path, Object^ obj ) { FileStream^ fileStrm ; try { //Serialize entire object into Binary stream
3
by: parrot toes | last post by:
Summary: I have been trying to make requests of a web service provided by Axis using a dotnet client with code generated by wsdl.exe and have been getting exceptions when trying to process the...
1
by: parrot toes | last post by:
I tried to post this question before, but there was an error when posting. I case it did get posted and in order to avoid duplication, I'll just repost a summary. I have written a dotnet client...
8
by: ashoksrini | last post by:
Hi All, I have the below requirement and would like to get some feeback from the group on the best way to implement: 1. I have WSDL defined exposing few web services. 2. We dont have a...
5
by: Greg Allen | last post by:
I am consuming a web service and using the generated Reference.cs to access the service and the objects associated with it. I have run into a problem where some inherited classes are not being...
8
by: Camellia | last post by:
Just a humble question, I tried to assign a real number with exponents to a variable but obviously I can't do: double a = 1e-10; The compiler will in turn complain about the undefined 'e'. So,...
2
by: =?Utf-8?B?TnV0c2hlbGw=?= | last post by:
Hey I am running into this issue. I have a Serializable Class that has a Double member. I am using XmlSerializer to serilaize this object, If the Double member is large (or very small) ,...
7
by: Andrew | last post by:
Hi, I am using DataContractJsonSerializer to deserialize JSON string in C# objects but I am having a problem. Suppose I have a class: class Item { public ItemId Id { get; set; }
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.