Код: Выделить всё
public record struct MyRecord(string Whatever = "anything"){
public DateTime Start {get; init;} = DateTime.UtcNow;
public DateTime? End {get; init;}
}
Если я предоставляю значение для любого из значений первичного конструктора (т.е. в парантеесах). Дело это приводит к тому, что начальное значение всегда будет 0 тика (т.е. 01/01/0001 00:00:00).
sharplabs
Почему он это делает?
Код: Выделить всё
[method:System.Runtime.CompilerServices.OverloadResolutionPriority(1)]
public record struct MyRecord(string Whatever = "anything"){
public DateTime Start {get; init;} = DateTime.UtcNow;
public DateTime? End {get; init;}
}
Подробнее здесь: https://stackoverflow.com/questions/749 ... aultrecord
Мобильная версия