string.Empty vs null.Which one do you use?

null and Empty are very different, and I don’t suggest arbitrarily switching between them. But neither has any extra “cost”, since Empty is a single fixed reference (you can use it any number of times).

There is no “pollution” on the stack caused by a ldsfld – that concern is…. crazy. Loading a null is arguably marginally cheaper, but could cause null-reference exceptions if you aren’t careful about checking the value.

Personally, I use neither… If I want an empty string I use "" – simple and obvious. Interning means this also has no per-usage overhead.


At the IL level, the difference here between “” and Empty is just ldstr vs ldsfld – but both give the same single interned string reference. Furthermore, in more recent .NET versions the JIT has direct interception of these, yielding the empty string reference without actually doing a static field lookup. Basically, there is exactly no reason to care either way, except readability. I just use “”.

Leave a Comment