Which is more efficient for the compiler and the best practice for checking whether a string is blank?
Also, does the answer depend on language?
An empty string is a String object with an assigned value, but its length is equal to zero. A null string has no value at all.
String arrays can contain both empty strings and missing values. Empty strings contain zero characters and display as double quotes with nothing between them ( "" ). You can determine if a string is an empty string using the == operator.
Therefore you should always use string. The compiler will "link" them all to an empty string. I read somewhere (sorry, I don't remember where) that the empty string is duplicated once in each assembly. So each assembly that uses "" instead of System. String.
Yes, it depends on language, since string storage differs between languages.
Length = 0
.[0] == 0
. .IsNullOrEmpty
.Etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With