just curious about it . i wonder why :
string str = @"//
// Use a new char[] array of two characters (\r and \n) to break
// lines from into separate strings. \n Use RemoveEmptyEntries
// to make sure no empty strings get put in the string array.
//";
result text to richTextBox was:
//
// Use a new char[] array of two characters (\r and \n) to break
// lines from into separate strings. \n Use RemoveEmptyEntries
// to make sure no empty strings get put in the string array.
//
but
string str = @"//
// Use a new char[] array of two characters (\r and \n) to break
// lines from into separate strings."+" \n" + @" Use RemoveEmptyEntries
// to make sure no empty strings get put in the string array.
//";
result text to richTextBox was:
//
// Use a new char[] array of two characters (\r and \n) to break
// lines from into separate strings.
Use RemoveEmptyEntries
// to make sure no empty strings get put in the string array.
//
There is no literal @ before your central string " \\n" The equivalent would be
string str = @"//
// Use a new char[] array of two characters (\r and \n) to break
// lines from into separate strings."+ @" \n" + @" Use RemoveEmptyEntries
// to make sure no empty strings get put in the string array.
//";
\\ is an escape character in normal strings, but string literals use the content exactly as is, except in the case of " which is escaped as ""
Because there is no @ before the "\\n" in you second example. Any escape sequence after @ (verbatim string literal) will be ignored. In your first example it was ignored but not in the second.
Have a look at this: http://msdn.microsoft.com/en-us/library/aa691090(v=vs.71).aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.