What is a string variable initialized to?

When you create a string variable in UiPath Studio and don’t set a default, what exactly is it initialized to under the hood? I’ve done tests and here’s what happens:

 IsNothing(mystrvar) => true   OR   mystrvar is Nothing => true
 mystrvar = ""  => true

Not sure how to test for null. IS THAT THE SAME AS “NOTHING”? (I come from a db background and null is something special).

So is it null, nothing, or empty? Or in UiPath, are they all the exact same thing?

@Terry_Marr,

Yes, string default value is null.

You can test it with Nothing.

String provides method to check it.
String.IsNullOrEmpty(strVariable)

In summary:

  1. An empty string ("") is different from Nothing and represents a string with no characters.
  2. Nothing is equivalent to null in other programming languages and signifies the absence of any value.

Thanks,
Ashok :slight_smile:

Use String.IsNullOrEmpty(yourVar)

Hi @Terry_Marr

In UiPath Studio, when you create a string variable and don’t set a default value, it is initialized to Nothing.

  • IsNothing(mystrvar) => true or mystrvar is Nothing => true indicates that mystrvar is indeed Nothing (uninitialized).
  • After mystrvar = "", the variable is no longer Nothing; it is an empty string.

You can use this also

String.IsNullorEmpty(mystrvar)

Hope you understand!!

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.