Repository navigation
ES CSharp Keyword using
Codex edited this page Oct 11, 2026
·
2 revisions
Українська · Русский · English · Deutsch · Français · Italiano · Español · 繁體中文 · 日本語 · 한국어
Importa nombres, establece un alias o administra un recurso IDisposable/IAsyncDisposable. La importación en sí no agrega la dependencia que falta.
Guarde este ejemplo por separado como Example.cs. Ejecútelo independientemente de los demás ejemplos de esta página.
Example.cs:
// PROJECT-EXAMPLE
using System;
using (var stream = new System.IO.MemoryStream())
{
stream.WriteByte(65);
Console.WriteLine(stream.Length);
}Resultado:
1
using Namespace; / using Alias = Type; / using var resource = ...; / await using ...;la declaración de uso es válida hasta el final del alcance. Para .csx use (...) { ... } si la declaración de nivel superior es ambigua para la sintaxis del script.
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);
}
}Fuente oficial: Microsoft Aprender.
ClassicUO — Bad Newbie & C# Scripts IDE