C# 支援哪些轉義序列?


以下是一個示例,展示如何在 C# 中顯示一些跳脫字元 −

示例

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!
This is on the next line!");    } }

有關 C# 中的完整轉義序列列表,請參見 −

跳脫字元說明模式
\a匹配鐘聲字元,\u0007。\a
\b在字元類中,匹配退格鍵,\u0008。[\b]{3,}
\t匹配製表符,\u0009。(\w+)\t
\r匹配回車鍵,\u000D。(\r 不等於換行符,
.)
\r
(\w+)
\v匹配垂直製表符,\u000B。[\v]{2,}
\f匹配換頁符,\u000C。[\f]{2,}

匹配換行符,\u000A。\r
(\w+)
\e匹配轉義符,\u001B。\e

更新時間: 21-06-2020

122 次瀏覽

開啟你的職業生涯

完成課程即可獲得認證

開始
廣告
© . All rights reserved.