title: Property valid indication in a C# class for value type properties
body: <p>I have a data stream that updates only parts of a full object each time. So of 10 properties, only 1 can actually be valid. I will anyways create a new instance of my class, but with only one property with valid data.</p>
  
  <p>I want to be able to indicate if a property is containing real data, and keeping the property a value type (so no nullable types). And all values are possible (so no 'INT_MAX' indicates invalid).</p>
  
  <p>Previously I have used an int32 as a binary mask to indicate valid properties, but that obviously has a limitation on the number of properties, and in a class hierarchy it becomes messy.
  I also applied get'ers on the mask, so a boolean SomePropertyIsValid-property was available, and that helped, but it doubled the properties made available. </p>
  
  <p>I'm heading towards using a bit-mask again, unless there are someone that has a great idea?</p>
  
  <hr>
  
  <p>Addition:
  I read a steam of UDP packages (~100k per sec) that comes from a third party. They are coded like this:</p>
  
  <pre><code>int32 id;     // Unique system id of the object being updated
  int32 mask;   // indicates which fields that are included in the message
  int32 fieldA; // If mask bit 0 is high
  float fieldB; // If mask bit 1 is high
  int32 fieldC; // If mask bit 2 is high
  int32 fieldD; // If mask bit 3 is high
  int32 fieldE; // If mask bit 4 is high
  </code></pre>
  
  <p>I have created a class that deserializes the UDP message. I create a new instance, or update an excising one if data from the same object id has been received before.  </p>
  
  <p>My class exposes all the fields as properties defined by an interface:</p>
  
  <pre><code>public interface IMessage
  {
    int Id {get; set;}
    int FieldA {get; set;}
    double FieldB {get; set;}
    int FieldC {get; set;}
    int FieldD {get; set;}
    int FieldE {get; set;}
  }
  </code></pre>
  
  <p>Now how do I indicate which properties that are actually updated?
  Pair and nullable types will double (or more) the memory used, so using a bit-mask (like the third party data source uses) doesn't seem like a bad idea, but I just wanted to check if there was some other nifty trick that doesn't have a large performance impact. </p>