Repository navigation
KO CSharp Keyword extern
Codex edited this page Oct 11, 2026
·
2 revisions
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
C# 코드 외부에서 구현된 멤버를 선언합니다. DllImport을 통한 기본 상호 운용성의 경우 일반적입니다. 외부 별칭은 외부 어셈블리 별칭을 지정합니다.
이 예제를 Example.cs로 따로 저장하고 이 페이지의 다른 예제와 독립적으로 실행하세요.
Example.cs:
// PROJECT-EXAMPLE
class NativeMethods
{
[System.Runtime.InteropServices.DllImport("kernel32.dll")]
public static extern uint GetCurrentProcessId();
}선언만 포함합니다. 이 코드는 라이브러리로 컴파일되며 실행하려면 Main에서 호출해야 합니다.
[DllImport(...)] public static extern ReturnType Method(...);이 두 가지 기본 예제는 Windows용입니다. 라이브러리 이름, ABI 및 기능 가용성은 플랫폼에 따라 다릅니다. 컴파일 자체에서는 해당 항목의 존재를 확인하지 않습니다.
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(Native.GetCurrentProcessId());
}
}
public static class Native { [DllImport("kernel32.dll")] public static extern uint GetCurrentProcessId(); }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(Native.GetTickCount64());
}
}
public static class Native { [DllImport("kernel32.dll")] public static extern ulong GetTickCount64(); }공식 출처: Microsoft 학습.
ClassicUO — Bad Newbie & C# Scripts IDE