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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T08:26:09+00:00 2026-05-24T08:26:09+00:00

Dim hex = 41 Dim text As New System.Text.StringBuilder For i As Integer =

  • 0
Dim hex = "41"
    Dim text As New System.Text.StringBuilder
    For i As Integer = 0 To hex.Length - 2 Step 2
        text.Append(Chr(Convert.ToByte(hex.Substring(i, 2), 16)))
    Next
    System.Diagnostics.Debug.WriteLine(text.ToString)

working perfectly.. System.Diagnostics.Debug.WriteLine writes the output itself in a new line.

 Dim hex = "4100"
    Dim text As New System.Text.StringBuilder
    For i As Integer = 0 To hex.Length - 2 Step 2
        text.Append(Chr(Convert.ToByte(hex.Substring(i, 2), 16)))
    Next
    System.Diagnostics.Debug.WriteLine(text.ToString)

but yet this fails.. (the output isn’t itself in a new line) what’s the explanation for that?

From what I know, doesn’t System.Diagnostics.Debug.Writeline does something which looks like this:

System.Diagnostics.Debug.Write(input)
System.Diagnostics.Debug.Write("\n")

so regardless of my input it should always have a newline char even if there is a terminating 00 char in my input?

  • 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-24T08:26:10+00:00Added an answer on May 24, 2026 at 8:26 am

    Here is the details describing what is going on here:

    The string class in .net is an array of char start by pointer to the first char in the array and ends by the special “terminal” char \0.

    When you convert the 00 to byte you get 0. but 0 is just equals the terminal char \0

    byte b = (byte)`\0`;\\the value of b will be 0
    

    So the Console.Write will ignore all characters after the first \0!. Not only the console will behive this way but also the control components. for instance textBox.Text if you apply a string to it that does have the \0 character, it will not will not display any character after \0 “including the \0 itself”.

    Edit:

    From what I know, doesn’t System.Diagnostics.Debug.Writeline does something which looks like this:

    System.Diagnostics.Debug.Write(input)
    System.Diagnostics.Debug.Write("\n")
    

    I guesses that the Debug.WriteLine are not implemented in this way or else we will not notice that behavior. maybe it does concatenate the string with new line like input + "\n".

    I can diagnosing the Console.WriteLine using Resharper program. the code is:

    [SecuritySafeCritical]
    public virtual void WriteLine(string value)
    {
        if (value == null)
        {
            this.WriteLine();
        }
        else
        {
            int length = value.Length;
            int num2 = this.CoreNewLine.Length;
            char[] destination = new char[length + num2];
            value.CopyTo(0, destination, 0, length);
            switch (num2)
            {
                case 2:
                    destination[length] = this.CoreNewLine[0];
                    destination[length + 1] = this.CoreNewLine[1];
                    break;
    
                case 1:
                    destination[length] = this.CoreNewLine[0];
                    break;
    
                default:
                    Buffer.InternalBlockCopy(this.CoreNewLine, 0, destination, length * 2, num2 * 2);
                    break;
            }
            this.Write(destination, 0, length + num2);
        }
    }
    

    So it is concatenate the string value with the new line. so it will cause the same effect.

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

Sidebar

Related Questions

On Error Resume Next Dim SQLData As New System.Data.SqlClient.SqlConnection(Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\ASPNETDB.MDF;Integrated Security=True;User Instance=True) Dim cmdSelect
Dim sb As StringBuilder = New StringBuilder() sb.Append(<script language=javascript>) sb.Append( function SetValueInBody() {) sb.Append(
Dim de As New System.DirectoryServices.DirectoryEntry() Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As
Dim box As MultiTextBox = New MultiTextBox Dim i As Integer for i =
Dim xbg As Rm xbg.LobId = cmb_lob.SelectedValue xbg.Mobile = mobno.Text xbg.BusinessFax = faxno.Text xbg.BusinessPhone
Dim objMail As New Mail.MailMessage(no-reply@mywebsite.com, ToEmail, Password Reset, body) ...and the problem is that
1 Dim x as Integer? = Nothing 2 If x = Nothing Then 3
Consider: Dim line As String Using readFile As New StreamReader(SalesUpdateFile) While (line = readFile.ReadLine)
Here is the sample: Dim TestString As String = Hello, & Chr(0) & World
I can do this: Dim fso As New FileSystemObject or I can do this:

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.