I am aware that I can set null like
string val = null;
But I am wondering the other ways I can set it to null. Is there a funcion like String.null
that I can use.
I think you are looking far String.Empty
string val = String.Empty;
Update: TheFuzzyGiggler comments are worth mentioning:
It's much better to set a
string
toempty
rather thannull
. To avoid exceptions later. If you have to read and write a lot of strings you'll havenull
value exceptions all over the place. Or you'll have a ton ofif(!string.isNullorEmpty(string))
which get annoying
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With