While trying to set Validations i initially encountered some problems with checking if a textbox is null, i tried using
private void btnGo_Click(object s
The difference is that ""
means and empty string but null
means it doesn't exist
In layman's term, null
means lacking of value and ""
mean zero-length string, which is not the same thing. There might be some piece of software that treat null
string and ""
equally e.g. Console.WriteLine
, but it still does not make them the same thing.
Strictly speaking, "" == null
expression is false
by design. The equality comparison of String
type in .NET framework works by == operator overloading, which does not treat null
as equal to ""
.
The default value of TextBox.Text
is String.Empty
or ""
not null. So your first code didn't work. null
is just to indicate that an object doesn't point to anything, it's not allocated with any memory.