Difference between Empty and Null

Posted by Rahuljgosavi under C# on 6/20/2011 | Points: 10 | Views : 19615 | Status : [Member] | Replies : 14
Dear All,

What is the difference between Empty String and Null value string , means exactly what goes in the memory point of view ?




Responses

Posted by: Lakn2 on: 6/20/2011 [Member] Starter | Points: 25

Up
0
Down
try this

http://stackoverflow.com/questions/265875/default-string-initialization-null-or-empty

Thanks&Regards
LakshmiNarayana Nalluri.

Rahuljgosavi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A4u6178 on: 6/20/2011 [Member] Starter | Points: 25

Up
0
Down
Hi ,
The difference between null and empty value string is that, the empty string is allocated a memory location with value "" and on the other hand the null value is just a pointer pointing nowhere in the memory (nonexistent value or nothing u say about the null value).

Thanks & Regards;
aaa

Rahuljgosavi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Naimishforu on: 6/21/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
Empty - It has empty value.
NULL - It has no value.

Thanks,
Naimish
http://dotnetinterview.zxq.net/
http://naimishpandya.blogspot.in/

Rahuljgosavi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Rahuljgosavi on: 6/21/2011 [Member] Starter | Points: 25

Up
0
Down
Which is the most efficient then , means in which scenario we need to use empty and null ?

Regards,
Rahul

Rahuljgosavi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: A4u6178 on: 6/21/2011 [Member] Starter | Points: 25

Up
0
Down
Hi Rahuljgosavi,

Try this link...
http://docs.intersystems.com/cache20081/csp/docbook/DocBook.UI.Page.cls?KEY=RSQL_null

Thanks & Regards;
aaa

Rahuljgosavi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Susanthampy on: 6/21/2011 [Member] [MVP] Bronze | Points: 25

Up
0
Down
string.Empty doesn't create an object 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 a string in memory that is created by default. On the other hand null is a the absense 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.

Regards,
Susan

Rahuljgosavi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vilasgite080 on: 6/21/2011 [Member] Starter | Points: 25

Up
0
Down
NULL : http://en.wikipedia.org/wiki/Null_(SQL)
Empty : http://en.wikipedia.org/wiki/Empty_string
---------------
If Its helps you. "MARK AS ANSWER!"


Rahuljgosavi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Karthikanbarasan on: 6/22/2011 [Member] [Moderator] [Microsoft_MVP] [MVP] Silver | Points: 25

Up
0
Down
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".



Thanks
Karthik
www.f5Debug.net

Rahuljgosavi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: perfectchourasia-9163 on: 6/8/2012 [Member] Starter | Points: 25

Up
0
Down
Empty - It has empty value.
NULL - It has no value.

String s = "";
s.lentgh; // return 0

String s = null;
s.lentgh;//returns a null pointer exception

ER sandeep chourasia
sandeepchrs@yahoo.com (on facebook)
http://www.aspnetcodes.com/

Rahuljgosavi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 6/8/2012 [Member] Bronze | Points: 25

Up
0
Down
NULL isn't allocated any memory, the string with NUll value is just a pointer which is pointing to nowhere in memory. however, Empty IS allocated to a memory location, although the value stored in the memory is

Rahuljgosavi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Muhsinathk on: 6/8/2012 [Member] Bronze | Points: 25

Up
0
Down
Mark as Answer if its helpful to you,that motivates...

Rahuljgosavi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sandeepmhatre on: 3/26/2013 [Member] Starter | Points: 25

Up
0
Down
Refer this link

http://sandeepmhatre.blogspot.com/2013/03/difference-between-stringempty-string.html

Sandeep M,
Software Developer
Follow me on :
http://sandeepmhatre.blogspot.in

Rahuljgosavi, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jitendrasoft09 on: 3/27/2013 [Member] [MVP] Starter | Points: 25

Up
0
Down
NULL is nothing means no value at all with not points in memory and Empty means no any value at all.
We can check and test the string null or empty with following code-

If(string.IsNullOrEmpty(EmptyOrNullValue));

Jitendra Kumar
If my post helps you, plz mark as an answer.

Rahuljgosavi, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response