In .NET prior to version 2.0, ""
creates an object while string.Empty
creates no objectref, which makes string.Empty
more efficient.
In version 2.0 and later of .NET, all occurrences of ""
refer to the same string literal, which means ""
is equivalent to .Empty
, but still not as fast as .Length == 0
.
.Length == 0
is the fastest option, but .Empty
makes for slightly cleaner code.
See the .NET specification for more information.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…