Solved

Clearing a Textbox

Posted on 2013-06-28
2
318 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
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: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering 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

Title # Comments Views Activity
Where did System.Data.Objects go? 2 41
C# bracket error 3 36
transaction in asp.net, sql server 6 43
How can I do Unit Testing with Session ? 1 13
Article by: Ivo
C# And Nullable Types Since 2.0 C# has Nullable(T) Generic Structure. The idea behind is to allow value type objects to have null values just like reference types have. This concerns scenarios where not all data sources have values (like a databa…
Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

820 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