Solved

Clearing a Textbox

Posted on 2013-06-28
2
328 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 110 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

MS Dynamics Made Instantly Simpler

Make Your Microsoft Dynamics Investment Count  & Drastically Decrease Training Time by Providing Intuitive Step-By-Step WalkThru Tutorials.

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…
We all know that functional code is the leg that any good program stands on when it comes right down to it, however, if your program lacks a good user interface your product may not have the appeal needed to keep your customers happy. This issue can…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

623 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