CKTIS / C#
get: practical reference
get: practical reference: get reads a property or indexer value and may execute code.
Version: C# language; verified against C# 14 reference
Syntax
get /* grammar-specific form */get reads a property or indexer value and may execute code.
Use it for controlled reads while keeping the getter fast and unsurprising.
A getter may throw or perform I/O although callers expect a field-like read.
A property may have get without set, and accessor visibility may be narrower.
The complete program actually uses get; its exact expected stdout is 8.
Examples
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;
Console.WriteLine(new Sample().Value);
sealed class Sample { public int Value { get => 8; } }
Result
8
The complete program actually uses `get`; its exact expected stdout is `8`.