empty character literal

  • Thread starter Thread starter Eranga
  • Start date Start date
E

Eranga

What is empty character literal and how can we get rid of it.
I want to check whether the text box is empty so I use
if (TextBox1.Text == '' ) Why cant I do this?
 
Eranga said:
What is empty character literal and how can we get rid of it.
I want to check whether the text box is empty so I use
if (TextBox1.Text == '' ) Why cant I do this?

Because there's no such thing as an empty character literal, and the
type of TextBox.Text is string, not char anyway.

You can use

if (TextBox1.Text == "")

to test whether it's an empty string.
 
Hi, you can use

if ( TextBox1.Text.Length ==0 ) ... // 0 = empty string

Nicolas Guinet
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top