title: C# XML serialize specific elements from an array
body: <p>I would like to serialize some specific elements of an array based on some condition.</p>
  
  <p>For Example:</p>
  
  <pre><code>public class Team 
  {
      public string Name {get; set;}  
      public Person[] Staff;}
  
  public class Person
  {
      public string Name {get; set;}
      public NrOfHolidays {get; set;}
  }
  </code></pre>
  
  <p>And when serializing the <code>Team</code> class I would like to serialize only those members from the <code>Staff</code> array that have a <code>NrOfHolidays</code> larger than 10 let's say.</p>
  
  <p>Is there a way this can be done?</p>
  
  <p>I know how the <code>ShouldSerialize[MemberName]</code> function can be used to serialize/not serialize a given member, but I don't know if it can be applied to elements of an array that is a member.</p>
  
  <p>Edit:
  Thanks for the replies.</p>
  
  <p>I just found this <a href="https://stackoverflow.com/questions/20955722/excluding-specific-items-in-a-collection-when-serializing-to-json">post</a>.
  This is the exact same problem I'm facing, but the solution proposed here is for JSON. I'm looking for a solution similar to the on proposed in the above post, which works for XML serialization.</p>