Difference between string str=" "; and string str1=string Empty

Pubblicato il: 16 marzo 2017
sul canale di: VCreations Tech
4,047
45

URL:- http://myjourneytodotnet.blogspot.in/...

Whenever we declare string str=""; then it will create a new object. But whenever we declare string str1=string.Empty then it will create no object which makes string.Empty more efficient. However, string.Empty is a read-only field whereas "" is a compile time Constant.
So, string str1=string.Empty is the most prefered way of Writing the code. But string.Empty can't use inside Switch Case Statement because as it is a read-only so it will generate error.


In questa pagina del sito puoi guardare il video online Difference between string str=" "; and string str1=string Empty della durata di ore minuti seconda in buona qualità , che l'utente ha caricato VCreations Tech 16 marzo 2017, condividi il link con amici e conoscenti, su youtube questo video è già stato visto 4,047 volte e gli è piaciuto 45 spettatori. Buona visione!