yatanadam
yatanadam

Reputation: 1264

How can i write \\\ in nsstring?

I must write "\\\" in my nsstring. I tried @"\\\" But it didn't work well. Can you help me? Thanks.

Upvotes: 1

Views: 297

Answers (4)

Matt Lacey
Matt Lacey

Reputation: 8255

Did you try @"\\\\\\"? You need to escape each of the slashes with another slash, because \ is used as an escape character, in sequences such as \n for new line.

Upvotes: 6

Pierre
Pierre

Reputation: 11663

If you want three \ you have to multiply it by to. So six \

Upvotes: 0

Manlio
Manlio

Reputation: 10864

Double the backslashes. Each one is an escape character, so to write a single \ you must write \\.

Upvotes: 1

Ashwin Singh
Ashwin Singh

Reputation: 7375

You need to escape each individual backslash. Use @"\\\\\\" in the above code. This will escape each individual backslash.

Upvotes: 0

Related Questions