How to make a text field empty in code

I have a text box (txtbox1) that has some meaning in it. I want to clear the value of a text field. Is this possible in code? If so, how?

Thank!

+5
source share
3 answers

Well:

txtbox1.Text = "";

must do it.

(Note that I usually prefer from ""to string.Emptyin terms of readability. Use what you prefer. Ignore any talk about performance differences between them - most of the articles I saw on this are outdated, and any performance difference may be completely inconsequential.)

+11
source
txtbox1.Text = string.Empty;
+8
source

textbox1.Text = null; textBox1.Text = "";

textBox1.Text = string.Empty;

0

All Articles