© 2026 Hedgehog Software, LLC

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

Nullable strings in .net 6

So I'm a little bit new to .NET 6 coming from .NET framework.

Do we have to make a
string
string
string?
string?
in .NET6 and above if it's nullable or can we ignore it? Say I have a parameter
void Foo(string str = null)
void Foo(string str = null)
, I get warned by rider because it says it's a null literal in a non-nullable reference type but it compiles just fine. Is it best practice to have the strings declared like
string?
string?
when nullable

So in the end, we use
string
string
when it wont ever be null and
string?
string?
when it is nullable in .net 6?
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

❔ .NET 6.0 - Nullable Strings with Dapper Model Classes
C#CC# / help
4y ago
Handling Nullable Property Updates in ASP.NET
C#CC# / help
2y ago
❔ Hardlink in Linux .NET 6.0
C#CC# / help
3y ago