?
Solved

Clearing a Textbox

Posted on 2013-06-28
2
Medium Priority
?
329 Views
Last Modified: 2013-06-28
if I had a text box named txtAnswer I could clear it with txtAnswer.Clear() or txtAnswer.Text = String.Empty()  Using the Clear() method would keep this statement shorter.  Is there any other reason why you would chose one method over the other?
0
Comment
Question by:M1Bill72
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 21

Accepted Solution

by:
Tapan Pattanaik earned 440 total points
ID: 39286219
Hi  M1Bill72,

 I would choose the TextBox.Clear() method, because it is logically better to clear a value, rather than re-assigning it with another value. But I wanted to do a little test...

for more details please check this link.

http://www.experts-exchange.com/Microsoft/Development/Microsoft_Programming/WPF_and_Silverlight/A_10775-WPF-TextBox-Text-String-Empty-vs-TextBox-Clear-vs-TextBox-ClearValue-vs-TextBox-SetValue.html
0
 
LVL 13

Expert Comment

by:jonnidip
ID: 39286285
Nice to see my article in a solution!
In short: if you only need to clear text, then the best is to assign String.Empty.

Regards.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Najam
Having new technologies does not mean they will completely replace old components.  Recently I had to create WCF that will be called by VB6 component.  Here I will describe what steps one should follow while doing so, please feel free to post any qu…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…

719 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question