I would like to serialize some specific elements of an array based on some condition.

For Example:

```
public class Team 
{
    public string Name {get; set;}  
    public Person[] Staff;}

public class Person
{
    public string Name {get; set;}
    public NrOfHolidays {get; set;}
}

```

And when serializing the `Team` class I would like to serialize only those members from the `Staff` array that have a `NrOfHolidays` larger than 10 let's say.

Is there a way this can be done?

I know how the `ShouldSerialize[MemberName]` 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.

Edit:
Thanks for the replies.

I just found this [post](https://stackoverflow.com/questions/20955722/excluding-specific-items-in-a-collection-when-serializing-to-json).
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.