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.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Jignesh TrivediRank #16 · 50.3K reputationPosted May 20, 2014, 11:34 PM EDT
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.
Lakshmanan Sethu SankaranarayanRank #124 · 17.7K reputationPosted May 21, 2014, 1:05 AM EDT
VulpesRank #55 · 29.2K reputationPosted May 21, 2014, 1:21 AM EDT
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 :)
Munesh SharmaRank #174 · 13.9K reputationPosted May 21, 2014, 1:26 AM EDT
this is best method to clear fields.
Nilesh AvhadRank #3,587 · 406 reputationPosted May 21, 2014, 2:26 AM EDT
tbx1.Text=string.Empty; is the proper way to write and understandable to others also.
Rajagopalan R VRank #6,801 · 256 reputationPosted May 21, 2014, 2:30 AM EDT
Thank You All For Your Valuable Points Got Clear Solution For This And For Mr.Lakshmanan Sethu
too
With Warm Regards......,
R.V.Rajagopalan