Serializing and Deserializing Value Types to String

  • Thread starter Thread starter Earl Teigrob
  • Start date Start date
E

Earl Teigrob

I am saving and restoring value types such as Int32, DateTime and Boolean in
strings. I was wondering if there is a mechanism build into .NET for
serializing and deserializing these to string format. I can, of course,
serialize a class to a file, either binary or XML, but this is not what I am
looking for. Currently I am using ToString() or Convert.xxx to do this, but
thought that if there was a true serializer, deserializer, that would be
perfect.

An example would be the way that a DateTime column in a DataTable is
serialized to XML. It is converted to the format
"2004-04-30T19:30:00.0000000-05:00". Microsoft has built a special DateTime
serializer into there XML converter to save (and restore) DateTime in a
string (for XML) format. This saves the time with maximum precision,
relative to MGT.

Can I access to class to do something similar?

Thanks for you Input

Earl
 
Hello

ToString will do the job. but just make sure you use the InvariantCulture
when serializing and deserializing.

Best regards,
Sherif
 
Sherif,

I am very familiar with ToString... but I am looking for a way to serialize
that this made for deserializing and restoring the original value (As in the
DateTime example) without losing any precision...

Anyone know about a class for this???

Earl
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top