using System.Diagnostics.CodeAnalysis;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
public static void Main()
var a = new TestBuffer();
"abc".AsSpan().CopyTo(a[..]);
Console.WriteLine($"a = '{a}'");
[StructLayout(LayoutKind.Explicit, Size = sizeof(char) * TestBuffer.Length)]
public char this[int index]
set => AsSpan()[index] = value;
public Span<char> this[Range range] => AsSpan()[range];
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public Span<char> AsSpan() => new SpanBuilder(ref _, Length);
public override string ToString() => AsSpan().ToString();
[StructLayout(LayoutKind.Explicit)]
public readonly ref struct SpanBuilder(ref char reference, int length)
private readonly Span<char> _span;
private readonly SpanLayout _spanLayout = new(ref reference, length);
private readonly ref struct SpanLayout(ref char reference, int length)
public readonly ref char Reference = ref reference;
public readonly int Length = length;
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static implicit operator Span<char>(SpanBuilder v) => v._span;
public int Length => this[..].Length;
public Buffer3(string value)
value.AsSpan().Slice(0, Math.Min(value?.Length ?? 0, this[..].Length)).CopyTo(this[..]);
this[..].Replace(' ', '\0');
public readonly override string ToString()
Span<char> temp = stackalloc char[3];
public static implicit operator string(Buffer3 v) => v.ToString();
public static implicit operator Buffer3(string v) => new(v);
public readonly struct Code(string value)
private readonly Buffer3 _value = value;
public override string ToString() => _value;
public static implicit operator Code(string v) => new(v);
public static implicit operator string(Code v) => v.ToString();
[StructLayout(LayoutKind.Explicit)]
public readonly record struct Record()
private static Record Default = new();
public Record(Record original) : this() => this = original;
private readonly Buffer80 _value;
public char this[int cardColumn]
get => _value[cardColumn - 1];
init => _value[cardColumn - 1] = value;
public Code Test1 { get; init; } = "ABC";
public char Test2 { get; init; }
public override string ToString()
Span<char> temp = stackalloc char[80];
Default._value[..].CopyTo(temp);