In Asp.net Difference between ""(empty string) and String.Empty
What is the difference between String.Empty and "" (empty string):
In Asp.net created String is an object of String Class.
String str=”” Creates an object
And
String.Empty creates no object.
So it is more efficient to use String.Empty.
Source of information
.Length == 0 is the fastest option,
But .Empty makes for
slightly cleaner code.
So "" is pretty equivalent to .Empty, but still
not as fast as .Length == 0.
string.Empty doesn't create an object while ""
creates a string object.
Difference between Empty String and Null value string:
Null is an absence of a value. An empty string is a value,
but is just empty.
Null is special to a database.
The difference between '1' and "1" for in a
database query is that the SQL syntax supports '1' for SQL queries, but doesn't
use "1".
Comments
Post a Comment