Skip to content

Instantly share code, notes, and snippets.

@richardcox13
richardcox13 / program.cs
Last active August 28, 2024 10:40
C# 13 (.NET 9) required definite assignment for struct typed out parameters
Console.WriteLine("Hello, World!");
static void GetADateOnly(int dayNo, out DateOnly result) {
if (dayNo == 0) { throw new ArgumentOutOfRangeException(nameof(dayNo)); }
var t = DateOnly.FromDateTime(DateTime.Now);
if (dayNo < 0) {
// Requied as DateOnly has a field... else get CS0177 on the next line
//result = t;