Solved

Clearing a Textbox

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

752 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