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 7492947
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T16:40:32+00:00 2026-05-29T16:40:32+00:00

I got a boolean list with 92 booleans, I want the list to be

  • 0

I got a boolean list with 92 booleans, I want the list to be converted to a string, I thought I ll take 8 booleans(bits) and put them in a Byte(8 bits) and then use the ASCII to convert it the byte value to a char then add the chars to a string. However after googeling for more then 2 hours, no luck atm. I tried converting the List to a Byte list but it didn t work either ^^.

String strbyte = null;
for (int x = 0; x != tmpboolist.Count; x++) //tmpboolist is the 90+- boolean list
{
   //this loop checks for true then puts a 1 or a 0 in the string(strbyte)
   if (tmpboolist[x])
   {
      strbyte = strbyte + '1'; 
   }
   else
   {
      strbyte = strbyte + '0';
   }
}

//here I try to convert the string to a byte list but no success
//no success because the testbytearray has the SAME size as the 
//tmpboolist(but it should have less since 8 booleans should be 1 Byte)
//however all the 'Bytes' are 48 & 49 (which is 1 and 0 according to
//http://www.asciitable.com/)
Byte[] testbytearray = Encoding.Default.GetBytes(strbyte); 

PS If anyone has a better suggestion on how to code & decode a Boolean list to a String?
(Because I want people to share their boolean list with a string rather then a list of 90 1 and 0s.)

EDIT: got it working now! ty all for helping

string text = new string(tmpboolist.Select(x => x ? '1' : '0').ToArray());
byte[] bytes = getBitwiseByteArray(text); //http://stackoverflow.com/a/6756231/1184013
String Arraycode = Convert.ToBase64String(bytes);
System.Windows.MessageBox.Show(Arraycode);
//first it makes a string out of the boolean list then it uses the converter to make it an Byte[](array), then we use the base64 encoding to make the byte[] a String.(that can be decoded later)

I ll look into the encoding32 later, ty for all the help again 🙂

  • 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-29T16:40:35+00:00Added an answer on May 29, 2026 at 4:40 pm

    You should store your boolean values in a BitArray.

    var values = new BitArray(92);
    values[0] = false;
    values[1] = true;
    values[2] = true;
    ...
    

    Then you can convert the BitArray to a byte array

    var bytes = new byte[(values.Length + 7) / 8];
    values.CopyTo(bytes);
    

    and the byte array to a Base64 string

    var result = Convert.ToBase64String(bytes);
    

    Reversely, you can convert a Base64 string to a byte array

    var bytes2 = Convert.FromBase64String(result);
    

    and the byte array to a BitArray

    var values2 = new BitArray(bytes2);
    

    The Base64 string looks like this: "Liwd7bRv6TMY2cNE". This is probably a bit unhandy for sharing between people; have a look at human-oriented base-32 encoding:

    Anticipated uses of these [base-32 strings] include cut-
    and-paste, text editing (e.g. in HTML files), manual transcription via a
    keyboard, manual transcription via pen-and-paper, vocal transcription over
    phone or radio, etc.

    The desiderata for such an encoding are:

    • minimizing transcription errors — e.g. the well-known problem of confusing
      ‘0’ with ‘O’
    • embedding into other structures — e.g. search engines, structured or
      marked-up text, file systems, command shells
    • brevity — Shorter [strings] are better than longer ones.
    • ergonomics — Human users (especially non-technical ones) should find the
      [strings] as easy and pleasant as possible. The uglier the [strings] looks, the worse.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Learning GAE I`ve got some issue. I want to save contact list of my
I've got a list of byte[] which i'd like to concatenate into one byte[]
I've got three boolean values A, B and C. I need to write an
I've got some dynamically-generated boolean logic expressions, like: (A or B) and (C or
I want to use CLR table-valued function in SQL Server 2008, which accesses a
In my Struts form I've got a list. In a JSP I iterate over
I want listfield with images and checkbox on right side of text. I got
I've got a table with a few boolean columns like: IsProductionWorker, IsMaterialHandler, IsShopSupervisor, etc.
I got list of crawlers from following website: http://www.karavadra.net/blog/2010/list-of-crawlers-bots-and-their-ip-addresses/#respond If you know better list
Say my java code has List<String> listS =null and i pass this to my

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.