First, the only difference between a string variable and a string literal is
that a string variable is a variable that may contain any string, while a
string literal is simply an immutable string. If you think of the variable
as a "box" that can contain any string, which can be an empty box, or have
any string put into it or removed from it, it should be helpful. Perhaps
your confusion arises because the programming syntax allows you to treat a
variable as if it *were* what it contains or points to. It is not.
The '@' token is not a character, but a programming token, which tells the
compiler to treat single backslash characters as literal backslash
characters when compiling a literal string. It is not part of a string, and
is not necessary to use to declare a literal string. So, what you're
actually saying is that you want to display an '@' character arbitrareily in
front of the string for some reason. Perhaps an illustration would help:
"abcde 12345"
@"abcde 12345"
These 2 expressions are exactly the same string. The syntax is simply a way
of providing instructions to the compiler as to what sort of data it should
store, how to identify it, and what the actual data should be.
--
HTH,
Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP
<ca*******@yahoo.comwrote in message
news:11**********************@t8g2000prg.googlegro ups.com...
Converting a string variable into a string literal. How do I add the
@ character in front of the string?
I cannot add it when the string is created as it will affect other
parts of the program.
I have tried these but they do not work:
label1.text = @S
label1.text = "@" + S
I want to be able to display the whole string with control characters
in a label.