Max Adams <ru************@hotmail.com> wrote:
How can I get this statement to work:
string strData = '\xB';
I get the error: Cannot implicitly convert type 'char' to 'string'.
Can anyone help?
Sure:
string strData = "\xB";
'' is used for specifying a single character.
"" is used for specifying a string.
And that will give me the code for the ASCII character <VT>??
Yup - although using "\v" would be simpler :)
On a related point though, when you *do* need to specify a Unicode
character in that kind of way, I'd suggest using \u instead - it's less
error prone. For instance, using your example:
"hello\xBworld" gives you what you want, but:
"hello\xBBob" doesn't, because the second B is treated as part of the
hex string too. Using
"hello\u000BBob" is fine though.
--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too