Hi.....,
Which is Best Method To Clear The Text in a Text box in C#
tbx1.Text="";
or
tbx1.Text=string.Empty;
With Regards.....,
R.V.Rajagopalan
Loading
Know the answer? Post it — somebody with the same question will find it here.
Sign in to answer this question
It is the same account you read, post and publish with — and you will come straight back to this page.
Jignesh TrivediPosted May 21, 2014, 3:34 AM
Hi,
As per me there is no difference between this two.
The value of string.Empty is the zero-length string, "".
Please refer
http://msdn.microsoft.com/en-us/library/system.string.empty.aspx
hope this will help you.
Rajagopalan R VPosted May 21, 2014, 6:30 AM
Thank You All For Your Valuable Points Got Clear Solution For This And For Mr.Lakshmanan Sethu
too
With Warm Regards......,
R.V.Rajagopalan
Nilesh AvhadPosted May 21, 2014, 6:26 AM
tbx1.Text=string.Empty; is the proper way to write and understandable to others also.
Munesh SharmaPosted May 21, 2014, 5:26 AM
this is best method to clear fields.
VulpesPosted May 21, 2014, 5:21 AM
tbx1.Clear();
which is perhaps the clearest of the three.
However, as Jignesh said, it makes no difference whatever which one you use - it's purely a matter of taste :)
Lakshmanan Sethu SankaranarayanPosted May 21, 2014, 5:05 AM