Final initializers
Summary
Final initializers are a proposed new kind of member declaration that runs at the end of an object's initialization—after constructors, object and collection initializers, and with expressions.
Early notes refer to these as "validators."
public class Range
{
public int Min { get; init; }
public int Max { get; init; }
init
{
if (Max < Min)
{
throw new InvalidOperationException("Max must not be less than min.");
}
}
}
Design meetings
2020-04-27: Initial decision on init {...} syntax
Final initializers
Summary
Final initializers are a proposed new kind of member declaration that runs at the end of an object's initialization—after constructors, object and collection initializers, and
withexpressions.Early notes refer to these as "validators."
Design meetings
2020-04-27: Initial decision on
init {...}syntax