Posts

Showing posts from June, 2013

C# How to Serialize/Deserialize BitVector32

I have a class with a property of type BitVector32, when I Serialize it, I noticed the property was not getting serialized because the BitVector32 is not [Serializable]. After thinking about how can I serialize this property and looking into the implementation of BitVector32 it became clear that I need to approach this from a different angle. BitVector32 class has a property called Data where the information is stored, this property is of type Int and Int is obviously [Serializable]. Here is my approach: [ Serializable ]      public   class   TreeItem     {          // Serializable requires an empty constructor           public  TreeItem()         {         }          public   int  Id {  get ;  set ; }          public   int  ObjectType {  get ;  set ; }         [ XmlIgnore ]          public   BitVector32   Properties  {  get ;  set ; }         [ XmlElement ( "Properties" )]          public   Int32  Data         {              get  {  return  Propertie