- var str = "";
- var str0 = String.Empty;
we can easily find out that str = str0; but which way is faster?
the following is the disassembly from the first statement:
Ldstr
Stloc_0 local_0
the following is the one from the second statement:
Ldsfld System.String.Empty
Stloc_1 local_1
It does not tell much, but when we actually run it using StopWatch, we can find the String.Empty is 5-6 times faster than empty string. I would not say the different is so huge because maybe it is my computer's configuration, but definitely the second statement is faster.
No comments:
Post a Comment