title: How to serialize an object containing an ILIST member into XML?
body: <p>I am trying to convert an object say User having multiple fields into an XML. The problem is that I get an exception when it tries to serialize an ILIST member.
  Following is the code I am using:</p>
  
  <pre><code>var stringwriter = new System.IO.StringWriter(); 
  var serializer = new XmlSerializer(User.GetType()); &lt;!-- Getting exception here --&gt;
  serializer.Serialize(stringwriter, User); 
  return stringwriter.ToString();
  </code></pre>
  
  <p>My User looks something like this: </p>
  
  <pre><code>class User
  {       public virtual string Name{ get; set; }
          public virtual DateTime? LastUpdated { get; set; }
  
          public virtual int? ContactId { get; set; }
  
          public virtual IList&lt;Sector&gt; Sectors { get; set; }
          public virtual AccessLevel AccessLevel { get; set; }
          public virtual IList&lt;UserRole&gt; UserRole { get; set; }
  }
  </code></pre>
  
  <p>Is there a way by which I can check if a member of the class whose object I am serializing is serializable or not and then tweak the logic for that particular member. I have less control over the user class. :( So any way where I could extend my code to handle IList members will be preferred.</p>