© 2026 Hedgehog Software, LLC

TwitterGitHubDiscord
More
CommunitiesDocsAboutTermsPrivacy
Search
Star
Setup for Free
C#C
C#•3y ago•
11 replies
EddieV

❔ Non-nullable property must contain a non-null value when exiting constructor

I know what it says and what it wants my to do. However, my situation is: I have a bunch of objects (as properties) and that not all of them needs instantiating in a main class constructor. Given a condition, some will be and some won't be.

In case of one that won't be, I still have no idea how to make the warning go away.

Any suggestion? I'm sure how to Google this since using the warning would send me to a non-desirable direction.
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

❔ Non-nullable property 'Name' must contain a non-null value when exiting constructor
C#CC# / help
3y ago
❔ Non-nullable field 'rating' must contain a non-null value when exiting constructor
C#CC# / help
4y ago
✅ Help with non-nullable field must contain a non-null value when exiting constructor.
C#CC# / help
3y ago
getting warning: CS8618 - Non-nullable variable must contain a non-null value when exiting construct
C#CC# / help
3y ago