Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. .NET (Core and Framework)
  4. StringBuilder.Append(Char(0)) Issues

StringBuilder.Append(Char(0)) Issues

Scheduled Pinned Locked Moved .NET (Core and Framework)
data-structuresquestion
1 Posts 1 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    AhClem
    wrote on last edited by
    #1

    I've been putting together a simple routine to parse a streamreader, using a StringBuilder object as a buffer. Dim streamBuffer(bufferSize) As Char Dim strBldr As New StringBuilder((bufferSize * 2) + 2) Dim reader As StreamReader Do If strBldr.Length < bufferSize Then Array.Clear(streamBuffer, 0, streamBuffer.Length) streamReadLength = reader.Read(streamBuffer, 0, bufferSize) **strBldr.Append(streamBuffer)** End If . . . What seems really weird is that only some passes through the loop the StringBuilder object's Length is incremented by the size of the streamBuffer's contents but the contents are not Appended to the StringBuilder. So, while the strBldr.Length will equal say 4096, the StrBldr.ToString().Length will equal 310 and StrBldr.ToString() will produce a string that is 310 characters in length. Meanwhile, the streamBuffer field will have an array of characters in it. I've searched unsuccessfully for any reports of bugs. Anyone got any ideas? Will

    1 Reply Last reply
    0
    Reply
    • Reply as topic
    Log in to reply
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes


    • Login

    • Don't have an account? Register

    • Login or register to search.
    • First post
      Last post
    0
    • Categories
    • Recent
    • Tags
    • Popular
    • World
    • Users
    • Groups