CKTIS / C#
using: praktická referencia
using: praktická referencia: using importuje namespace či alias alebo deterministicky uvoľní IDisposable.
Verzia: C# language; verified against C# 14 reference
Syntax
using /* grammar-specific form */using importuje namespace či alias alebo deterministicky uvoľní IDisposable.
Deklaráciu using umiestnite bezprostredne po získaní prostriedku.
Import môže spôsobiť konflikt názvov; using bez await neobslúži IAsyncDisposable.
Dispose sa vykoná pri opustení rozsahu, aj cez return alebo výnimku.
Úplný program skutočne používa using; presne očakávaný stdout je line.
Príklady
using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;
using var reader = new StringReader("line"); Console.WriteLine(reader.ReadLine());
Výsledok
line
Úplný program skutočne používa `using`; presne očakávaný stdout je `line`.