String Relace

  • Thread starter Thread starter dave
  • Start date Start date
D

dave

How do i Replace a character with a nul value

like this but this does not work
oNewString=oString.Replace('a','')
I Want to Replace a character with a NON Space

Thanks
DAve
 
Realise that you are REMOVING the letter and not replacing it and all shall
be revealed on how to solve this problem ;)
 
Hi,

dave said:
How do i Replace a character with a nul value

What u meant with "null" ?

like this but this does not work
oNewString=oString.Replace('a','')
I Want to Replace a character with a NON Space

Your code does that, it replace 'a' with a NON space, more eactly it just
remove the 'a'

With what u want to replace it with?
 
Thanks Daniel...i Feel like a dummy......staring right in front of me.....
 
Remove works (as has been pointed out), but I frequently use Replace with
empty strings. I think it works with strings, but not chars....
Ethan
 
Remove works (as has been pointed out), but I frequently use Replace with
empty strings. I think it works with strings, but not chars....

That's because there's no such thing as an "empty char".
 
code snippet

is the below the appropriate way to remove characters insid a sting or is
there a better solution



int iChr;

while ((iChr = oBufferOut.IndexOf('"'))>0)

{

oBufferOut=oBufferOut.Remove(iChr,1);

}
 
DaveP said:
code snippet

is the below the appropriate way to remove characters insid a sting or is
there a better solution

int iChr;

while ((iChr = oBufferOut.IndexOf('"'))>0)
{
oBufferOut=oBufferOut.Remove(iChr,1);
}

Yup - use oBufferOut.Replace ("\"", "");
 
kshitij kumar said:
use
Replace(strString,'a','NULL')

Which language are you thinking of here? The above isn't valid C#, as
'NULL' isn't a valid character literal - and you'd want to call the
Replace method *on* strString, not with strString as the first
parameter.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top