ZH TW CSharp Directive Pragma - LIHACHTETAN/ClassicUO-Bad-Newbie-CSharp-Scripts-IDE GitHub Wiki
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
診斷管理
警告禁用/恢復更改選定的警告。 checksum 指定生成源的调试信息的校验和。
簡單範例 (Example.cs)
請將此範例另存為 Example.cs,並與本頁其他範例分開執行。
Example.cs:
// PROJECT-EXAMPLE
#pragma warning disable CS0168
int unused;
#pragma warning restore CS0168
System.Console.WriteLine("Ready");
結果:
Ready
句法
#pragma warning disable CODE / restore CODE
範例1
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
public static class Program
{
public static async Task Main(string[] args)
{
#pragma warning disable CS0168
int unused;
#pragma warning restore CS0168
Console.WriteLine("Ready");
}
}
範例2
#pragma checksum "Generated.cs" "{8829d00f-11b8-4213-878b-770e8597ac16}" "00112233445566778899AABBCCDDEEFF"
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;
public static class Program
{
public static async Task Main(string[] args)
{
Console.WriteLine("Source mapped");
}
}
官方來源:Microsoft學習。