title: Do I really need to write this "SerializationHelper"?
body: <p>I just wrote this <strong>SerializationHelper</strong> class, but I can't believe this is necessary!  </p>
  
  <pre><code>using System.IO;
  using System.Xml.Serialization;
  
  public static class SerializationHelper
  {
      public static string Serialize&lt;T&gt;(T obj)
      {
          var outStream = new StringWriter();
          var ser = new XmlSerializer(typeof(T));
          ser.Serialize(outStream, obj);
          return outStream.ToString();
      }
  
      public static T Deserialize&lt;T&gt;(string serialized)
      {
          var inStream = new StringReader(serialized);
          var ser = new XmlSerializer(typeof(T));
          return (T)ser.Deserialize(inStream);
      }
  }
  </code></pre>
  
  <p>And it's used like this:</p>
  
  <pre><code>var serialized = SerializationHelper.Serialize(myObj);
  </code></pre>
  
  <p>and:</p>
  
  <pre><code>var myObj = SerializationHelper.Deserialize&lt;MyType&gt;(serialized)
  </code></pre>
  
  <p>Am I missing something in the .NET framework?  This is not rocket science!</p>