Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 678671
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T01:10:32+00:00 2026-05-14T01:10:32+00:00

I have a business class which I need to serialize to xml. It has

  • 0

I have a business class which I need to serialize to xml. It has a BitArray property.

I have decorated it with [XmlAttribute] but the serialization is failing with

To be XML serializable, types which inherit from ICollection must have an implementation of Add(System.Boolean) at all levels of their inheritance hierarchy. System.Collections.BitArray does not implement Add(System.Boolean).

I am not sure whether its possible to serialize to xml?

If not what would be an efficient means of serializing the BitArray

Thanks for looking

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T01:10:32+00:00Added an answer on May 14, 2026 at 1:10 am

    You cannot directly serialize a BitArray to XML. The reason is that in order to de-serialize it you’d need an Add method which BitArray doesn’t supply.

    You can, however, copy it to an array that can be serialized:

    BitArray ba = new BitArray(128);
    int[] baBits = new int[4];  // 4 ints makes up 128 bits
    
    ba.CopyTo(baBits, 0);
    // Now serialize the array
    

    Going the other way involves deserializing the array and calling the BitArray constructor:

    int[] baBits;  // This is deserialized somehow
    BitArray ba = new BitArray(baBits);
    

    If you do this, you’ll want your BitArray size to be a multiple of the word size (i.e. if you use an array of int, then your BitArray size should be a multiple of 32).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have a input tag which is non editable, but some times i need
I have a business case whereby I need to be able to specify my
I have some business objects which use: Web.Configuration.WebConfigurationManager.AppSettings.Item(SomeSetting) Now that I'm breaking those objects
If I have a business object with 50 fields, and I need to populate
A lot of the time I will have a Business object that has a
Lets say I have business class: public class Foo { public int Prop1 {get;set;}
I have a parent class, like this: public abstract class Business<T> : IBusiness<T> where
I have a business model which consists of a parent/child relationship (Identifier/IdentifierValue) and also
I have a business user who tried his hand at writing his own SQL
I have a business logic classes that are written in pure C# (without any

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.