Differences of Strings???????

Posted by Sabarimahesh under C# on 4/12/2012 | Points: 10 | Views : 1031 | Status : [Member] | Replies : 9
string s = "";
string h = null;
string w = string.Empty;

What is the Difference Between These three

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M



Responses

Posted by: Hariinakoti on: 4/12/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Mahesh,

string.empty handles memory efficently than string x="";
"" actually creates an object but string.empty does not.

Thanks&Regards
Hari


Thanks & Regards
Hari

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

Posted by: Sakthi.Singaravel on: 4/12/2012 [Member] Silver | Points: 25

Up
0
Down
@hari,
its informative for me..

Regards,
Singaravel M

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

Posted by: Hariinakoti on: 4/12/2012 [Member] Starter | Points: 25

Up
0
Down
@Singaravel


No dude,
i found in my class notes.

Thanks & Regards
Hari

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

Posted by: Sakthi.Singaravel on: 4/12/2012 [Member] Silver | Points: 25

Up
0
Down
@hari
any way thanks for sharing..

Regards,
Singaravel M

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

Posted by: Sabarimahesh on: 4/12/2012 [Member] Bronze | Points: 25

Up
0
Down
@ Hari

Any elaborate answers..

Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

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

Posted by: Kk86kiran on: 4/12/2012 [Member] Starter | Points: 25

Up
0
Down
Hi Mahesh,

Hari is right but another point is also there that is if you want to create object on heap it is better to use " " but if you want to give reference you use .Empty.

And String.Empty is only a read only field but " " is a constant so you can't use string.Empty in switch statement becoz it's not a constant.

k.m.j.kiran

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

Posted by: Hariinakoti on: 4/12/2012 [Member] Starter | Points: 25

Up
0
Down
@Mahesh

Thank you Mahesh

Thanks & Regards
Hari

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

Posted by: Sabarimahesh on: 4/13/2012 [Member] Bronze | Points: 25

Up
0
Down
Hariinakoti

Yes ....Wwlcome


Life is a Race
Thanks & Regards
By
Sabari Mahesh P M

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

Posted by: Sakthi.Singaravel on: 4/13/2012 [Member] Silver | Points: 25

Up
0
Down
@kiran
thank you

Regards,
Singaravel M

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

Login to post response