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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T14:23:15+00:00 2026-06-11T14:23:15+00:00

I’m a self-made programmer, therefore I don’t know much about bits and bytes and

  • 0

I’m a self-made programmer, therefore I don’t know much about bits and bytes and hexadecimal values.

One of the libraries I use receives data from a remote service as byte array. I have found a method to convert this byte array data:

public string ByteArrayToHexString(byte[] buf)
{
    if (buf == null) return "";

    StringBuilder sb = new StringBuilder(buf.Length * 2 + 2);

    for (int i = 0; i < buf.Length; i++)
    {
        sb.Append(buf[i].ToString("x2"));
    }

    return sb.ToString();
}

Using this method I get strings like these:

0031

or

0022

or

002d

Are those actual values sent by the service or should further conversion required? What should I do to get the actual values?

  • 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-11T14:23:16+00:00Added an answer on June 11, 2026 at 2:23 pm

    I’m going to make no attempt to answer the question as to what your byte values mean, or whether they are “correct”, because we have no way of knowing, given the information presented here. Instead I’m going to take you through your conversion, step by step, to answer your question “Are those actual values sent by the service?”

    A byte[] is an array of bytes – a “byte array”.

    An array is a fixed size set of values.

    A byte object in C# is a value whose range falls between the decimal numbers 0 and 255.

    So a “byte array” is literally just a bunch of numbers, in order, all of which are between 0 and 255.

    Hexadecimal values are just one way to visualise a byte array.

    (And for complete clarity, hexadecimal is base 16, decimal is base 10.)

    The numbers in the columns below are equivalent.

    decimal    0     5    10    15    16    20     26     255
    decimal    0    05    10    15    16    20     26     255  (padded with zero)
    hex        0     5     a     f    10    14     1A      FF
    hex        0    05    0a    0f    10    14     1A      FF  (padded with zero)
    

    So imagine an array of bytes with the following decimal values:

    4, 12, 255, 1, 0
    

    That’s equivalent to an array of bytes with the following hexadecimal values:

    4, c, ff, 1, 0
    

    That can also be written as:

    04, 0c, ff, 01, 00
    

    or more commonly:

    0x04, 0x0c, 0xff, 0x01, 0x00
    

    or:

    04 0c ff 01 00
    

    or:

    040cff0100
    

    So if your service is returning a byte array and you’re seeing values like 002d, that means, you received two bytes, first byte is 0 (0 is the same in base 10 and base 16), second byte is 2d (hex) which can also be expressed as 45 in decimal (base 10).

    Short answer, notwithstanding anything you’ve not told us, yes, those hexadecimal values do represent the actual values received from the service.

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

Sidebar

Related Questions

I don't have much knowledge about the IPv6 protocol, so sorry if the question
I am reading a book about Javascript and jQuery and using one of the
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I know there's a lot of other questions out there that deal with this
Does anyone know how can I replace this 2 symbol below from the string
I'm making a simple page using Google Maps API 3. My first. One marker
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

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.