Repository navigation
KO CSharp Keyword using
Codex edited this page Oct 11, 2026
·
2 revisions
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
이름을 가져오거나 별칭을 설정하거나 IDisposable/IAsyncDisposable 리소스를 관리합니다. 가져오기 자체는 누락된 종속성을 추가하지 않습니다.
이 예제를 Example.cs로 따로 저장하고 이 페이지의 다른 예제와 독립적으로 실행하세요.
Example.cs:
// PROJECT-EXAMPLE
using System;
using (var stream = new System.IO.MemoryStream())
{
stream.WriteByte(65);
Console.WriteLine(stream.Length);
}결과:
1
using Namespace; / using Alias = Type; / using var resource = ...; / await using ...;using 선언은 범위가 끝날 때까지 유효합니다. .csx의 경우 최상위 선언이 스크립트 구문에 대해 모호한 경우 using (...) { ... }를 사용하세요.
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)
{
using var stream = new MemoryStream();
stream.WriteByte(65);
Console.WriteLine(stream.Length);
}
}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)
{
await using var stream = new MemoryStream();
await stream.WriteAsync(new byte[] { 1, 2, 3 });
Console.WriteLine(stream.Length);
}
}공식 출처: Microsoft 학습.
ClassicUO — Bad Newbie & C# Scripts IDE