Why doesn't the apostrophe get created in a string?

  • Thread starter Thread starter Johann Blake
  • Start date Start date
J

Johann Blake

I want the following string to be created:

hello "Bob"

This is how I've been doing it up till now...

string s = "hello\"bob\"";

An alternative is...

string s = "hello ""Bob""";

Why is that it no longer works on my system? I keep getting

"hello\"Bob\""

No matter what I do, the backslash is always included. I even shut
down VS and restarted to no avail. Why all of a sudden doesn't this
work?

Thanks for your insight,
Johann Blake
 
Are you putting a @ in front of your string literal? e.g.

string s = @"hello\"world\"" ?

The @ will make the compiler ignore \ codes within string lits. to make it
easier to enter paths and the like.

HTH

Kieran
 
Back
Top