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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T13:51:40+00:00 2026-06-16T13:51:40+00:00

I want to write the following sequence of bits in a textbox, like this:

  • 0

I want to write the following sequence of bits in a textbox, like this:

000101100000000100000001000000010000000000100111001100010010000000110000001011100011000000110000001100000011000000100000001100110011100100101110001101110011010100100000001100000010111000110000001110000010000000110000001011100011000000110000001000000011000000101110001100000011000000110000001100000000010111010111

But every each 8 bits corresponds to a byte, so I want to store them in a byte[] array. Of course, if I read them like this:

byte[] byteBuffer = Encoding.ASCII.GetBytes(messageTextBox.Text);

Each 0 or 1 turns into a whole byte, which is not what I want.

Is there any straightforward solution, like some existing method, or I have to develop my own?

  • 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-06-16T13:51:42+00:00Added an answer on June 16, 2026 at 1:51 pm

    I have written the following code on the go without any compiler so please apologize syntax errors – also you have to take care of reaching the end of the text string on your own, its not included. I think the below method does what you want to do ..

    private bytes[] extractBytes (string text) {
    
        byte[] bytes = new byte[100];
        int i = 0;
        int j = 0;
        string currentByte = "";
    
        while (i <= text.Length) {
    
             currentByte += text.Substring(i, 1);
    
             i++;
    
             if (i % 8 == 0) {
    
                 j++;
    
                 bytes[j] = convertToDecimal(currentByte);
                 currentByte = "";
             }
        )
    
        return bytes;
    }
    

    If you want to save the decimal value that is represented by the binary value you have extracted from your string you can use this conversion method:

    private byte convertToDecimal (string binary) {
    
        int i = 0;
        int byte = 0;
    
        while (i < s.Length) {
    
            if (s.Substring(s.Length - 1 - i, 1).Equals("1")) {
    
                sum += (byte)Math.Pow(2, i);
            }
    
            i++;
        }
    
        return sum;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to write a SQL query like the following. Its syntax is not
I want to write the following JS code but I am not sure if
I want to write the following in Clojure, but I can't figure it out
I want to write the following procedure / function: procedure ShowSysPopup(aFile: string; x, y:
I want to write the following C# code equivalent in JavaScript/jQuery (x == 0
I want to write my xml with following format. How can i do it?I
I want to write a .xml file using the following code into the App_Data/posts.
I want to write a procedure to perform a delete for the following i
I wrote the following regex in perl and now i want to write it
I want to create URL re-write rules for following URL in htaccess. http://example.com/vedios/category/fun/ ->

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.