String.Empty vs String. Length: And why String.IsNullOrEmpty
Comparing against String.Length == 0 is faster.
· Length is stored and need not to be calculated.
· Numeric operations are in itself faster than String
Though it is faster, it will throw an exception in case the string is null.
Empty string (“”)
So overall better is String.IsNullOrEmpty(someString). It safely works as below.
· On Null strings as no exception is thrown
· On Empty strings as no object object instance is created. See Post.
Thanks & Regards,
Arun Manglick || Senior Tech Lead