Search code examples
stringvb.netcontainsuipath

Why a string that has some value is returning true when checking if it contains ""?


A scenario where the variable tempMID of type string containing value "338715618884", checks if it contains "" or not. It is returning true. Why is this happening? in my understanding, this shouldn't return true.

enter image description here


Solution

  • That's documented:

    String.Contains returns true if the value parameter occurs within this string, or if value is the empty string (""); otherwise, false.

    So it's working as expected. The language designer have decided that an empty string is contained in every existing string, which makes sense to me.