Check to see if a string is empty


There are several ways to check a string to see if it’s empty.  However, you should try to always use the following method.  It’s faster, and uses less resources.  This may seem like a minimal piece of code - but if you were checking strings through out your application, it all adds up in the end.

        string strAmIEmpty = "";

 

        if (strAmIEmpty.Length == 0)

        {

            // empty so do something

        }

Comments (0)

Skip to main content