-- 作者:admin
-- 发布时间:11/9/2004 2:25:00 AM
-- C#中的特殊字符换码
发信人: billsteven (痴痴的我在傻傻的等), 信区: DotNET 标 题: C#中的特殊字符换码 发信站: BBS 水木清华站 (Mon Aug 11 11:28:31 2003), 转信 ' \' " \" \ \\ Alert \a Backspace \b Form feed \f New Line \n Carriage Return \r Horizontal Tab \t Vertical Tab \v A Unicode character specified by its number, for example, \u200 \u A Unicode character specified by its hexadecimal code, for example, \xc8 \x null \0 (zero) The second approach is to use 'verbatim string' literals. These are defined by enclosing the required string within a leading at-sign and two double quotes (@"string").To illustrate this, to set the variable 'path' to the following value: C:\My Documents\ we could either escape the back-slash characters string path = "C:\\My Documents\\" or use a verbatim string thus: string path = @"C:\MyDocuments\" Strings written using the verbatim string syntax can span multiple lines, and whitespace is preserved. The only character that needs escaping is the double-quote character, the escape sequence for which is two double-quotes together. For instance, suppose that you want to set the variable 'text' to the following value: the word "big" contains three letters. Using the verbatim string syntax, the command would look like this: string text = @"the word ""big"" contains three letters." -- ★ 在我英雄年少时,有一个女生,她愿意为我失去生命..... ★ ★ 她意志坚定地说:你再缠著我,我就去死.... ★ ★ 在我负笈外地时,有一个女生,她愿意等我到下辈子..... ★ ★ 她温柔婉约地说:你想成为我男朋友,等下辈子吧.... ★ ★ 在我穷困潦倒时,有一个女生,她愿意与我共赴黄泉.... ★ ★ 她眼眶泛红地说:你再不还我钱,我就与你同归於尽.... ★ ※ 修改:·billsteven 于 Aug 11 11:32:48 修改本文·[FROM: 159.226.67.181] ※ 修改:·billsteven 于 Aug 11 12:10:22 修改本文·[FROM: 159.226.67.181] ※ 来源:·BBS 水木清华站 smth.org·[FROM: 159.226.67.181] 上一篇 返回上一页 回到目录 回到页首 下一篇
|