public static T Clone<T>(T t)
{
      T clone;
      System.Xml.Linq.XDocument doc = new System.Xml.Linq.XDocument();

      System.Xml.XmlWriter w = doc.CreateWriter();

      System.Xml.Serialization.XmlSerializer s = new System.Xml.Serialization.XmlSerializer(typeof(T));
      s.Serialize(w, t);
      w.Flush();
      w.Close();
      clone = (T)s.Deserialize(doc.CreateReader());
           
      return clone;
}