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

  • Home
  • SEARCH
  • 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 3343056
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T00:54:38+00:00 2026-05-18T00:54:38+00:00

Is there a BitArray alternative for the .NET Micro Framework? I was thinking about

  • 0

Is there a BitArray alternative for the .NET Micro Framework?
I was thinking about simply using a bool[], but how can you convert it back
into a byte[] ?

In the full framework, considering “bits” is a BitArray, the following works:

byte[] data = new byte[dimensions / 8];
bits.CopyTo(data, 0);

But I cannot seem to find the BitArray class in the micro framework

  • 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-18T00:54:39+00:00Added an answer on May 18, 2026 at 12:54 am

    It’s not terribly difficult to duplicate the functionality of BitArray. First, if you need fewer than 65 bits, then you can do it with a long or smaller.

    To set an individual bit:

    void Set(ref long ba, int bit)
    {
        ba |= 1L << bit;
    }
    

    To clear a bit:

    void Clear(ref long ba, int bit)
    {
        long mask = 1L << bit;
        mask = ~mask;
        ba &= mask;
    }
    

    To see if a bit is set:

    bool IsSet(long ba, int bit)
    {
        long mask = 1L << bit;
        return (ba & mask) != 0;
    }
    

    If you have more than 64 bits, then you’ll need to create an array (byte[], probably), and do the division to determine which byte/bit you want to modify. The methods above will work, provided you change the long to byte.

    For example, if you have:

    byte[] myBytes = new byte[128];
    

    You have 1024 bits.

    To set a bit:

    void Set (int bit)
    {
        int byte = bit/8;
        int bitIndex = bit%8;
        myBytes[byte] |= (byte)(1 << bitIndex);
    }
    

    The other methods use the same math to get the byte and bit index, and setting, clearing, and testing a bit is the same as with the long example above.

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

Sidebar

Related Questions

Is there a generic BitArray in .NET? I only found the non-generic one. Can
There's http://www.amazon.com/gp/product/0321278542/ but it looks a bit dated. Specificaly, it talks about bits that
There is something strange going on. I am using Zend Framework on a subfolder
There's a lot of reading on self referencing problems, but I can't seem to
With enum under .net the biggest number you can use is ULong. This mean
Is there a way to convert an int to a bitmask? example: int i
I'm using Dipperstein's bitarray.cpp class to work on bi-level (black and white) images where
There's a lot of examples for ActionScript over the web using trace() to print
There is a known issue with using jquery fadeOut, fadeIn, and fadeToggle, when fading
There are things like f.call(...) f.apply(...) But then there's this (1, alert)('Zomg what is

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.