CKTIS / C#
System.DateOnly: praktická reference
System.DateOnly: praktická reference: DateOnly představuje kalendářní datum bez denního času a časového pásma.
Verze: .NET API; verified on .NET 10.0.14
Syntaxe
System.DateOnly /* select a documented member or constructor */DateOnly představuje kalendářní datum bez denního času a časového pásma.
Použijte jej pro narozeniny, termíny a pracovní dny, které nejsou okamžiky na globální časové ose.
Parsování a formátování závisí na kultuře; vytvoření okamžiku vyžaduje také TimeOnly a časové pásmo.
Podporovaný rozsah je 0001-01-01 až 9999-12-31; operace za jeho hranicí vyvolají výjimku.
Úplný program skutečně používá System.DateOnly; přesně očekávaný stdout je 2026-11-17.
Pří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 date = new DateOnly(2026, 11, 17);
Console.WriteLine(date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture));
Výsledek
2026-11-17
Úplný program skutečně používá `System.DateOnly`; přesně očekávaný stdout je `2026-11-17`.