CKTIS / C#
interface: practical reference
interface: practical reference: interface defines a member contract without instance identity and may provide default implementations.
Version: C# language; verified against C# 14 reference
Syntax
interface /* grammar-specific form */interface defines a member contract without instance identity and may provide default implementations.
Use it for small interchangeable roles implemented by different types.
Changing a public interface affects every implementer; default methods complicate dispatch.
A class may implement many interfaces, while explicit implementation is visible only through the contract.
The complete program actually uses interface; its exact expected stdout is 3.
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;
IValue value = new Value(); Console.WriteLine(value.Read());
interface IValue { int Read(); } sealed class Value : IValue { public int Read() => 3; }
Result
3
The complete program actually uses `interface`; its exact expected stdout is `3`.