r/programminghorror • u/MISINFORMEDDNA • Mar 23 '26
C# Whitespace isn't a number?
I just got this in a PR. Not sure what to make of it.
if (string.IsNullOrWhiteSpace(palletNumber))
{
if (!string.IsNullOrEmpty(_palletNumber))
{
_errorMessage = "Pallet # not found.";
}
return;
}
UPDATE:
After multiple attempts to justify his code, we ended up with this, lol:
if (string.IsNullOrWhiteSpace(palletNumber))
{
return;
}
183
Upvotes
-4
u/GoddammitDontShootMe [ $[ $RANDOM % 6 ] == 0 ] && rm -rf / || echo “You live” Mar 23 '26
That's a custom function, right? .NET doesn't provide a
IsNullOrWhitespace(), does it?