C#C
C#4y ago
Thinker

Default struct with default value [Answered]

I have this struct
public readonly struct RuntimeConfiguration
{
    public int MaxLineCount { get; init; } = 10_000;



    public RuntimeConfiguration()
    {
    }
}

I also have a method which takes a parameter RuntimeConfiguration configuration = default, yet this default instance does not have MaxLineCount set to the value 10000? Does default only initialize the struct with every field to its type's default value, and not any user-provided default value?
Was this page helpful?