An empty string is a zero length string, a string that is equal to null (""), or not assigned. In some languages, you can check if a string is empty by comparing it to an empty string (""). Some languages distinguish between nil and null ("") so checking if the length is 0 is easier.
Delphi Prism Empty String Check
In Prism, a string can be nil (unassigned), assigned an empty string (""), or assigned a value. Therefore, to check if a string is empty, you have to check against both nil and (""). Alternatively, you can check the length of the string or use String.IsNullOrEmpty.
Syntax Example:
var s: String;
if (s = nil) or (s = '') then MessageBox.Show("empty string");
or use length:
if length(s) = 0 then MessageBox.Show("empty string");
Using IsNullOrEmpty
The .NET framework provides a IsNullOrEmpty static method as part of the String class. Remember, the syntax to use a static method is always ClassName.MethodName and you do not have to create the class ahead of time because it is static.
var s: String;
//Unassigned check. If String.IsNullOrEmpty(s) then MessageBox.Show("empty or null string");
//Assigned a non-zero value. s := "health care reform";
If Not String.IsNullOrEmpty(s) then MessageBox.Show("string contains a non zero value");
//Empty string. s := "";
If String.IsNullOrEmpty(s) then MessageBox.Show("empty or null string");