Sunday, August 2, 2009

String.Empty vs empty quotes vs String.Length

The usage of String.Empty is more efficient that the usage of empty quotes.

When using empty quotes an object is created and this produces more assembly code on the execution stack and for string.Empty is NO object created.

The usage of String.Length == 0 is the best. Now there is a numeric compare applied instead of a string compararision, and numeric compare is quicker.


Only what if the string has the value null? So use string.IsNullOrEmpty method


More info: C# Shiznit, Vikram's Blog

No comments:

Post a Comment