top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Empty String in ASP.net

+2 votes
394 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 LinkedIn 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 ]*$";

...