title: Generic of type T where T has a specific attribute
body: <p>Is it possible to create a generic method of type <code>T</code> where <code>T</code> has a specific attribute? </p>
  
  <p>E.g.:</p>
  
  <pre><code>public static XmlDocument SerializeObjectToXml&lt;T&gt;(T obj)
  {
      //...
  }
  </code></pre>
  
  <p>and I want to serialize only a classes with a <code>Serializable</code> and/or <code>DataContract</code> attribute:</p>
  
  <pre><code>[Serializable]
  [DataContract(Name = "viewModel", Namespace = "ns")]
  internal class ViewModel
  {
      //...
  }
  </code></pre>