top button
Flag Notify
    Connect to us
      Facebook Login
      Site Registration Why to Join

Facebook Login
Site Registration

Empty String in ASP.net

+2 votes
62 views

What is difference between these three -

textbox1.text = "" 
textbox1.text = null 
textbox1.text = string.empty

Any specific case when each of them is used?

posted Apr 2, 2014 by Khusboo

Share this question
Facebook Share Button Twitter Share Button Google+ Share Button LinkedIn Share Button Multiple Social Share Button

1 Answer

+1 vote
 
Best answer

textbox1.text = "" and textbox1.text = string.empty both are same,will return empty string, in this case compiler will allocates memory for string with zero length.but with textbox1.text = null no space is allocated trying to acess will throw null pointer exception.

answer Apr 2, 2014 by Pavan P Naik
Similar Questions
+1 vote

This example shows you how to check given input contains only numbers (digits) or not using regular expression in asp.net and c#.

Regular expression
string strRegexpNumber = @"^[0-9 ]*$";

Contact Us
+91 9880187415
sales@queryhome.net
support@queryhome.net
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Bangalore-560102
Karnataka INDIA.
QUERY HOME
...