Ignore a class property with marshalling
<p>I need to export an ObservableCollection of this class to a binary file:</p>

<pre><code>[StructLayout(LayoutKind.Sequential)]
[XmlRoot("RxFrame")]
public class RxFrame : BaseClass
{
    [XmlAttribute]
    public string ID { get; set; } = "00000000";

    [XmlAttribute]
    public int IntVal{ get; set; } = 0;

    [XmlAttribute]
    public bool IsExtended { get; set; } = false;

    public RxFrame()
    {
    } 
}
</code></pre>

<p>and this is the function to export the data to binary:</p>

<pre><code>[StructLayout(LayoutKind.Sequential)]
public class BaseClass
{
    public BaseClass()
    { }

    public virtual byte[] getBinaryData()
    {
        int size = Marshal.SizeOf(this);
        IntPtr ptr = Marshal.AllocHGlobal(size);
        byte[] buffer = new byte[Marshal.SizeOf(this)];
        Marshal.StructureToPtr(this, ptr, false);
        Marshal.Copy(ptr, buffer, 0, Marshal.SizeOf(this));
        Marshal.FreeHGlobal(ptr);
        return buffer;
    }
}
</code></pre>

<p>And this is the loop over each element:</p>

<pre><code>using (FileStream mstream = File.Open(filePathParam + "RX.bin", FileMode.Create))
{
   BinaryWriter bWriter = new BinaryWriter(mstream, Encoding.UTF8);
   bWriter.Write(ListeRxFrames.Count);
   foreach (RxFrame rx in ListeRxFrames)
   {
       bWriter.Write(rx.getBinaryData());
   }
   bWriter.Close();
}
</code></pre>

<p>This is working fine, but I only need to export the <code>IntVal</code> and <code>IsExtended</code> properties of the RxFrame class to binary. How do I do this?</p>