Computer >> บทช่วยสอนคอมพิวเตอร์ >  >> การเขียนโปรแกรม >> C#

Escape Sequences ที่ C# รองรับ

ตัวอย่างการแสดง Escape Characters

using System;
using System.Collections.Generic;

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

ตาราง Escape Sequences หลัก

Escape CharacterคำอธิบายPattern
\aBell (\u0007)\a
\bBackspace (\u0008)[\b]{3,}
\tTab (\u0009)(\w+)\t
\rCarriage Return (\u000D)\r\n(\w+)
\vVertical Tab (\u000B)[\v]{2,}
\fForm Feed (\u000C)[\f]{2,}
\nNew Line (\u000A)\r\n(\w+)
\eEscape (\u001B)\e