CKTIS / C#
type system: praktická referencia
type system: praktická referencia: Typový systém definuje hodnoty, konverzie, generic constraints, nullability a dispatch.
Verzia: C# language and .NET 10 reference runtime
Syntax
// type systemTypový systém definuje hodnoty, konverzie, generic constraints, nullability a dispatch.
Používajte typy na kódovanie invariantov a obmedzenie neplatných stavov.
Anotácie nullable sú analýza kompilátora, nie runtime validation.
Variance, boxing, dynamic a reflexia oslabujú niektoré statické záruky.
Úplný program skutočne používa type system; presne očakávaný stdout je 4.
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;
object value = "text"; if (value is string text) Console.WriteLine(text.Length);
Výsledok
4
Úplný program skutočne používa `type system`; presne očakávaný stdout je `4`.