Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

how do I print a single backslash

I want to print c: est

if I use

      string IN = "C:	est";

it's coming out as

      "C:	est"

and if I use

      string IN = @"C:	est";

it's coming out as

      "C:\test"

what's going on ?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
309 views
Welcome To Ask or Share your Answers For Others

1 Answer

I assume by "coming out" you mean how it looks in the debugger or some other visualization. The debugger shows all control characters, so it uses \ to indicate one slash. Otherwise you wouldn't know if meant a slash followed by a t or a Tab character.

Either of these should give you the appropriate string:

string IN = @"C:	est";

or

string IN = "C:\test";

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...