© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•4y ago•
3 replies
Thinker

Default struct with default value [Answered]

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



    public RuntimeConfiguration()
    {
    }
}
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
RuntimeConfiguration configuration = default
, yet this default instance does not have
MaxLineCount
MaxLineCount
set to the value 10000? Does
default
default
only initialize the struct with every field to its type's default value, and not any user-provided default value?
C# banner
C#Join
We are a programming server aimed at coders discussing everything related to C# (CSharp) and .NET.
61,871Members
Resources

Similar Threads

Was this page helpful?
Recent Announcements

Similar Threads

set default value of parameter to other parameter [Answered]
C#CC# / help
4y ago
✅ abstract class - default value
C#CC# / help
3y ago