March 26, 2013

Difference between string.Empty , string = "" , string = null



string.Empty doesn't create an object.

on other hand "" creates a string object
as string is a reference type, For each time when you declare a string values as "" it create a new object for the same string.
while string.Empty just reference a string in memory that is created by default.

In case of string value is equal to null refers to absence of characters, NULL is NOT a value.

It is a state  indicating that the object value is unknown or nonexistent.

It is not zero or blank or an “empty string” and it does not behave like any of these values.

1 comment: