Stripping ASCII from a string

  • Thread starter Thread starter S
  • Start date Start date
S

S

I need to strip some ASCII from a string. I am used to the VB ASC and CHR
methods but not sure in C#,


Any help?
 
string s = "ABC";
char[] cArray = s.ToCharArray();
Console.WriteLine("cArray is {0} characters.", cArray.Length);
foreach (char c in cArray)
{
Console.WriteLine("Char code is:"+ (int)c);
}
 
I need to strip some ASCII from a string. I am used to the VB ASC and
CHR methods but not sure in C#,


Any help?

System.Text.ASCIIEncoding.GetBytes("somestring");

--
------ooo---OOO---ooo------

Peter Koen - www.kema.at
MCAD CAI/RS CASE/RS IAT

------ooo---OOO---ooo------
 
string s = "ABC";
char[] cArray = s.ToCharArray();
Console.WriteLine("cArray is {0} characters.", cArray.Length);
foreach (char c in cArray)
{
Console.WriteLine("Char code is:"+ (int)c);
}

But that's Unicode and not ASCII
you need to call the GetBytes Method from ASCIIEncoding to get the desired
bytes.

--
------ooo---OOO---ooo------

Peter Koen - www.kema.at
MCAD CAI/RS CASE/RS IAT

------ooo---OOO---ooo------
 
But that's Unicode and not ASCII
Yes thanks. The Ascii example did not survive the send (too fast) key.
Cheers!
--wjs
 
Yes thanks. The Ascii example did not survive the send (too fast) key.
Cheers!
--wjs

*geeee*
I know that problem. happens to me about ten times a day :)

--
------ooo---OOO---ooo------

Peter Koen - www.kema.at
MCAD CAI/RS CASE/RS IAT

------ooo---OOO---ooo------
 
*geeee*
I know that problem. happens to me about ten times a day :)

Yup - I'm hoping that the newsreader I use (Gravity) is going to go
open source. If it does, I'm going to try to implement a send delay, so
that it waits 5 minutes before actually sending anything. The number of
times I've seen a mistake the moment I hit send is nobody's business...
 
S said:
I need to strip some ASCII from a string. I am used to the VB ASC and CHR
methods but not sure in C#,

Could you say exactly what you mean by "strip some ASCII"? What data do
you have beforehand, and what data do you want afterwards?
 
Another very useful feature is you can copy and paste right into OE (maybe
others) without a round-trip to notepad first to remove the formating and
munge the tabs, etc.
 
Back
Top