String.Empty is faster than "" because it doesn't create a new string object instance. Creating new instances brings
penalties on both execution speed and memory usage.
Example:
Example:
// Slowest
str1 == "";
// Slow
str1.Equals(" ") == false
//Fast
str1 == String.Empty
// Fastest
str1.Equals(String.Empty) == false
No comments:
Post a Comment