Jump to content
Xtreme .Net Talk

Recommended Posts

Posted (edited)

I know the following code doesn't work (.Chars is read-only), but hopefully you'll understand what I am wanting to do:

 

I want to cycle through sBuffer to remove certain QUOTE characters that are contained within certain phrases. Is there a method that is writable that I can copy the valid characters into? Something similar to the .Chars method, but also writable.

 

While iOldIndx < iFileLength
     If (sBuffer.Chars(iOldIndx) <> """") Then
          'keep this character by copying to the new buffer
          sNewBuf.Chars(iNewIndx) = sBuffer.Chars(iOldIndx)
          iNewIndx += 1
     End If
     iOldIndx += 1
End While

 

tia,

flynn

Edited by flynn
Posted

You could simply amend the new char to the end of a string for example

Dim sNewString as String = ""
While iOldIndx < iFileLength
     If (sBuffer.Chars(iOldIndx) <> """") Then
          'keep this character by copying to the new buffer
          sNewString += sBuffer.Chars(iOldIndx)
     End If
     iOldIndx += 1
End While

however if your buffer is over a few chars long (which i'm assuming it will always be), then you should do as you say and use the string builder.

Anybody looking for a graduate programmer (Midlands, England)?
  • Leaders
Posted
You could also create a Char array. The string class has a ToChars function which returns the string in the form of a Char array, and a char array can be cast to a string (at least in VB). A Char array will have less overhead, but the StringBuilder is probably easier.
[sIGPIC]e[/sIGPIC]

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...