Extending and filtering C# arrays
<p>I have been doing a lot of <code>List&lt;SomeType&gt;</code> - > <code>SomeType[]</code> conversion lately, especially when I'm filtering or extending arrays.</p>

<p>For example filtering:</p>

<pre><code>// filter the list
var memberList = new List&lt;MemberType&gt;();
foreach (var member in members)
{
    if (member.someProperty != sentinalValue)
    {
        memberList.Add(member);
    }
}
// overwrite the old array with a new on dimensioned correctly
members = new MemberType[memberList.Count];
memberList.CopyTo(members);
</code></pre>

<p>or extending:</p>

<pre><code>// create the new member
var newMember = new MemeberType();
// create a new array to hold the extended members
newMembers = new MemberType[members.Length + 1];
// copy over the old members
members.CopyTo(newMembers, 0);
// add the new member
newMembers[members.Length] = newMember;
// overwrite old array with new array containing new member
members = newMembers;
</code></pre>

<p>I have to use arrays (MemberType[]) instead of a nice generic collection because of the XML Serialization classes we use. I feel confident there is a nicer way to do this simple sort of thing so if you know of one (that doesn't add undue complexity) let me know.</p>
