Johnrad
Johnrad

Reputation: 2655

Backslash Escape Sequence displaying both backslashes

I currently have a string like this:

string login = "DOMAIN\" + userID

Obviously this does not work as I need the backslash escape sequence, right?

string login = "DOMAIN\\" + userID

This displays DOMAIN\\jcwhisman with 2 backslashes?

I have tried all of these in hopes that something will work. While these don't all display 3 slashes, none of them display what I need:

I know some of those don't seem logical, but I have just been trying everything I can.

I need it to display as DOMAIN\jcwhisman

Upvotes: 0

Views: 318

Answers (1)

Selman Genç
Selman Genç

Reputation: 101701

Your two ways are correct and should give you exactly what you want:

  1. string login = @"DOMAIN\" + userID

  2. string login = "DOMAIN\\" + userID

Just make sure that you don't have a backslash at the beginning of your userID.

Upvotes: 1

Related Questions