Computer >> Hướng Dẫn Máy Tính >  >> Lập Trình >> C#

Các chuỗi thoát (Escape Sequences) được hỗ trợ trong C#

Ví dụ hiển thị các ký tự thoát trong C#:

Ví dụ

using System;
using System.Collections.Generic;

class Demo {
    static void Main() {
        Console.WriteLine("Warning!" + '\u0007');
        Console.WriteLine("Test \t Demo Text");
        Console.WriteLine("This is it!\nThis is on the next line!");
    }
}

Danh sách đầy đủ escape sequences:

Ký tự thoátMô tảMẫu
\aChuông, \u0007.\a
\bBackspace trong lớp ký tự, \u0008.[\b]{3,}
\tTab, \u0009.(\w+)\t
\rCarriage return, \u000D. (Khác \n).\r\n(\w+)
\vVertical tab, \u000B.[\v]{2,}
\fForm feed, \u000C.[\f]{2,}
\nNew line, \u000A.\r\n(\w+)
\eEscape, \u001B.\e