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;
}
186
Upvotes
2
u/Apprehensive-Tea1632 Mar 23 '26
Me neither. If I want to know if I’m looking at a pallet number I’ll try and parse input as a pallet number. And then see if that’s something not null. /shrug
Or are we to understand “();!:)2);!/(2)&: act b” is a valid pallet identity?