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

Facebook Login
Site Registration

Empty String in

+2 votes

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 and c#.

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

Contact Us
+91 9880187415
#280, 3rd floor, 5th Main
6th Sector, HSR Layout
Karnataka INDIA.