How to de @ a string?

R

Russell Wyatt

I have a vb class which returns a string to my C# app. I'm finding that if
escape characters are included in the string the C# string becomes a @
string and the escape chars are ignored.

Unfortunately I need the escape characters.

Anyone know of a way I can either avoid this behaviour or to convert the
@string back to a regular C# string?

Russell
 
G

Guest

It is best to use a byte[]. This will make sure that all characters are
there. You can also use a Char[].
 
J

Jon Skeet [C# MVP]

landagen said:
It is best to use a byte[]. This will make sure that all characters are
there. You can also use a Char[].

No, it's *not* best to use a byte[] - then you have to deal with
encoding issues. Using a char[] is equivalent to using a string.
 
J

Jon Skeet [C# MVP]

Russell Wyatt said:
I have a vb class which returns a string to my C# app. I'm finding that if
escape characters are included in the string the C# string becomes a @
string and the escape chars are ignored.

Unfortunately I need the escape characters.

Anyone know of a way I can either avoid this behaviour or to convert the
@string back to a regular C# string?

I think you're getting a bit confused here - probably by the debugger.
"@strings" *are* regular C# strings. The debugger just shows the
strings in different ways to try to be helpful. Unfortunately it causes
a lot of confusion :(

To check what characters are *actually* in your string, do something
like:

foreach (char c in myString)
{
Console.WriteLine ((int)c);
}

and then have a look at what those characters are on www.unicode.org.
 

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

Top