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
 
Back
Top