The two are easy to remember. In fact, the English version is better to remember. The forward is called a slash, and the backward is called a backslash.
In windbg, the value of a filter member of directorysearcher is as follows:
0: 014>! Do RDX
Unable to enumerate managed locals, hresult 0x80004001
Unable to enumerate managed locals, hresult 0x80004001
Name: system. String
Methodtable: 000007fef91a7c6
Eeclass: 000007fef8dae530
Size: 414 (0x19e) bytes
GC generation: 0
(C: \ WINDOWS \ Assembly \ gac_64 \ mscorlib \ 2.0.0.0 _ b77a5c561934e089 \ mscorlib. dll)
String: (& (objectsid = \ 01 \ 05 \ 00 \ 00 \ 00 \ 00 \ 00 \ 05 \ 15 \ 00 \ 00 \ EE \ 94 \ 83 \ 48 \ 54 \ 46 \ C0 \ 31 \ 27 \ dB \ 8f \ 4f \ C4 \ 73 \ 04 \ 00 ))
Fields:
MT field offset type vt attr Value Name
000007fef91aee88 4000096 8 system. int32 1 instance 195 m_arraylength
000007fef91aee88 4000097 C system. int32 1 instance 99 m_stringlength
000007fef91a9660 4000098 10 system. Char 1 instance 28 m_firstchar
000007fef91a7c6 4000099 20 system. String 0 shared static empty
> Domain: Value 0000000000131320: 00000000ff490370 0000000002709600: 00000000ff490370 <
000007fef91a9510 400009a 28 system. Char [] 0 shared static whitespacechars
> Domain: Value 0000000000131320: 00000000ff490ac0 0000000002709600: 000000019f4955f0 <
Write section C #CodeWhen we use this value to query users in AD, we find that the slash here encountered a problem during compilation.
I tried to add a @ symbol before the string, but it was useless. I still cannot compile it.
Convert all the backslashes into double backslashes. This value is correct, as shown below:
.
Verify
Here we use some knowledge of escape characters in C #.
C # defines the following character escape sequences:
-
\ '
-single quote, needed for character literals
-
\ "
-double quote, needed for string literals
-
\\
-backslash
-
\ 0
-Unicode Character 0
-
\ A
-Alert (character 7)
-
\ B
-backspace (character 8)
-
\ F
-form feed (character 12)
-
\ n
-New Line (character 10)
-
\ r
-carriage return (character 13)
-
\ t
-horizontal tab (character 9)
-
\ v
-vertical quote (character 11)
-
\ uxxxx
-Unicode escape sequence for character with hex value XXXX
-
\ XN [N] [N] [N]
-Unicode escape sequence for character with hex value NNNN (variable length version of \ uxxxx)
-
\ uxxxxxxxx
-Unicode escape sequence for character with hex value XXXXXXXX (for generating surrogates)
Of these,\
,\ F
,\ V
,\ X
And\ U
Are rarely used in my experience.
[Author: Jon Skeet]
@ Symbol
The string prefixed with @ is called verbatim string. For example:
The path format is considered ugly and embarrassing.
String Path = "C :\\ Program Files \ Microsoft Visual Studio 10.0 \\";
A more convenient version is to use verbatim string
String Path = @ "C: \ Program Files \ Microsoft Visual Studio 10.0 \";
Verbatim string (@"... ") considers the content as pure content and does not need to escape any characters. however, a character must be escaped even in verbatim string, that is, the embedded double quotation marks ("), which must be escaped (""). example:
String xml = @ "<? XML version = "" 1.0 ""?> <DATA>... <DATA> ";
Reference
============================
What character escape sequences are available?
Http://blogs.msdn.com/ B /csharpfaq/archive/2004/03/12/what-character-escape-sequences-are-available.aspx
Escape sequences
Http://msdn.microsoft.com/en-us/library/h21280bw.aspx
Escaping in C #: characters, strings, string formats, keywords, identifiers
Http://www.codeproject.com/Articles/371232/Escaping-in-Csharp-characters-strings-string-forma