Empty string is not null but has zero length:
string emptyString = "";
// an empty string is not null...
assert(emptyString !is null);
// ... but it has zero lenght
assert(emptyString.length == 0);
string nullString = null;
a null string is null (De Lapalisse)
assert(nullString is null);
but, unlike C#, read the length of a null string does not generate error:
assert(nullString.length == 0);
assert(nullString.empty);
if (emptyOrNullString.length == 0) {
}
// or
if (emptyOrNullString.length) {
}
// or
import std.array;
if (emptyOrNullString.empty) {
}
if (nullString is null) {
}