© 2026 Hedgehog Software, LLC

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

❔ empty string not being recognized

string name = nameHolder.text;
if (String.IsNullOrEmpty(name))
{
    name = "New Save";
}
string name = nameHolder.text;
if (String.IsNullOrEmpty(name))
{
    name = "New Save";
}

I started with
if(name == "")
if(name == "")

tried
string.Empty
string.Empty

but when give it an empty name, and in debug I can see its an empty string, the statement is always false.
I am using unity, am I missing something obvious?
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

Blazor WASM in NET 8component not being recognized
C#CC# / help
3y ago
✅ Reference not recognized
C#CC# / help
3y ago
Not being able convert from string to int
C#CC# / help
3y ago
Next page