Thursday, August 2, 2012

Difference between null and String.Empty

1. string statement=null : means no object exists; null is not a value, it is a state indicating that object value is unknown or does not exists.

2. string statement = String.Empty : use of string.Empty doesn't create any objects  while "" creates a string object. So using string.Empty is better than using "" because every time you use "", it creates a new string while string.Empty just reference s string in memory that is created by default.

No comments:

Post a Comment