CKTIS / C#
in: praktická referencia
in: praktická referencia: in označuje vstup cez readonly referenciu alebo v syntaxi query viaže rozsahovú premennú na zdroj; nie je to operátor členstva.
Verzia: C# language; verified against C# 14 reference
Syntax
in /* grammar-specific form */in označuje vstup cez readonly referenciu alebo v syntaxi query viaže rozsahovú premennú na zdroj; nie je to operátor členstva.
Použite pre veľké structs, keď meranie potvrdí prínos vynechanej kópie.
Kompilátor môže vytvoriť defensive copy pri volaní iba zdanlivo readonly člena.
Podľa explicitného či implicitného zápisu in môže byť argument premenná alebo dočasná hodnota.
Úplný program skutočne používa in; presne očakávaný stdout je 9.
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;
var value = 9; Console.WriteLine(Read(in value)); static int Read(in int value) => value;
Výsledok
9
Úplný program skutočne používa `in`; presne očakávaný stdout je `9`.