CKTIS / C#
using: praktična referenca
using: praktična referenca: using uvozi namespace ali alias oziroma deterministično sprosti IDisposable.
Različica: C# language; verified against C# 14 reference
Sintaksa
using /* grammar-specific form */using uvozi namespace ali alias oziroma deterministično sprosti IDisposable.
Deklaracijo using postavite takoj po pridobitvi vira.
Uvoz lahko povzroči spore imen; using brez await ne obravnava IAsyncDisposable.
Dispose se izvede ob izhodu iz obsega, tudi prek return ali izjeme.
Celoten program dejansko uporabi using; natančno pričakovani stdout je line.
Primeri
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());
Rezultat
line
Celoten program dejansko uporabi `using`; natančno pričakovani stdout je `line`.