Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What language decision in C# annoys you? [closed]

Tags:

c#

I was just dealing with strings, and I find myself annoyed that strings can be nullable. So, I have to have

if((teststring??string.Empty)==string.Empty)

all over the place. Would string? have been so hard for allowing nullability in the relatively few cases where it is needed (dbs, idiot user inputs, etc.). I also find myself irritated with having to export readonly interfaces in the cases where I want some form of const correctness. So, what C# language construct/decision annoys you?

EDIT: Thanks for the isnullorempty function, I hadn't seen that before! Still doesn't lessen my annoyance at it being nullable :D

like image 462
Steve Avatar asked Mar 13 '09 14:03

Steve


1 Answers

Testing strings for Null or Empty is best done using:

if (string.IsNullOrEmpty(testString))
{
}
like image 194
Mitch Wheat Avatar answered Oct 15 '22 10:10

Mitch Wheat