Sorry, I don't know what I'm doing recently. I can't spare any time to write a blog. It's too lazy.
Recently, I am confused about some of the strings. Sort it out.
1. Differences between string and string
Just like Int Is Actually system. int32, string is a key word mapped to the system. String FCL type and is the alias of system. String. There is no difference in usage, because the compiler will compile the string as system. String.
2. When string is null, S = string. Empty; S = ""; S. Length = 0; Difference
Generally, these three methods are equivalent. Performance is slightly different.
The order of performance from high to low is:
S. Length = 0 is better than S = string. Empty is better than S = ""
After compilation, we can see that.
-----------------------------------------------------------------
> Str. Length = 0
Ldloc.0
Callvirt instance int32 [mscorlib] system. String: get_length ()
> Str. = string. Empty
Ldloc.0
Ldsfld string [mscorlib] system. String: empty
Callvirt instance bool [mscorlib] system. String: equals (string)
> STR = ""
Ldloc.0
Ldstr ""
Call bool [mscorlib] system. String: op_equality (string, string)