I am confused with below code. Which one is better to use. Can you explain the differences between them.
I am C# learner...
string ss = "";
string ss = string.Empty;
string = null;
I am confused with below code. Which one is better to use. Can you explain the differences between them.
I am C# learner...
string ss = "";
string ss = string.Empty;
string = null;
""
and String.Empty
are synonyms. They both refer to an empty string. Which one to use is a matter of preference. The following question contains various opinions on that topic:
In C#, should I use string.Empty or String.Empty or "" to intitialize a string?
null
refers to a null reference. The difference between an empty string and a null reference is detailed in the following question: