Skip to content

JA CSharp Directive Pragma

Codex edited this page Oct 11, 2026 · 2 revisions

Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어

診断の管理

ディレクトリ C# · 実践的な指導

警告の無効化/復元は、選択した警告を変更します。 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 Learn。

Clone this wiki locally