BizTalk Utilities CV ,   Jobs ,   Code library
 
Go to the front page to continue learning about XML or select below:

Contents

ReBlogger Contents

Previous posts in XML

 
 
Page 70 of 21350

TryXmlSerialize function

Blogger : Michael Freidgeims Blog
All posts : All posts by Michael Freidgeims Blog
Category : XML
Blogged date : 2009 Mar 21

I was using XmlSerialize method from 

http://serialization.codebetter.com/blogs/brendan.tompkins/archive/2005/03/01/56244.aspx

for a while.

Recently I found that sometimes it's safer to use TryXmlSerialize:

    /// <summary>
    /// Serialize an object into XML
    /// </summary>
    /// <param name="serializableObject">Object that can be serialized</param>
    /// <returns>Serial XML representation</returns>
    public static bool TryXmlSerialize(object objectToSerialize, out string strXml)
    {
        bool bRet=true;
        try
        {
          strXml =XmlSerialize( objectToSerialize);
        }
        catch (Exception exc)
        {
            bRet=false;
            strXml=exc.ToString();
        }
        return bRet;
    }
 


Read comments or post a reply to : TryXmlSerialize function
Page 70 of 21350

Newest posts
 

    Email TopXML