Class Act

Back to the shelf

VB.net · Snippet · ASP.net

Nothing vs empty string

VB.net: the difference between Nothing (no string at all) and an empty string ('').

Example

How to use Nothing vs empty string:
Paste the code into the class or page, then call it from the method that needs the result.

Notes

IsNullOrEmpty is true for both. A database NULL arrives as Nothing. Always check IsNullOrEmpty before calling methods on the value.

Code

If String.IsNullOrEmpty(text) Then
    text = ""
End If