Check If A String Is Not NULL Or EMPTY
Answer :
if (-not ([string]::IsNullOrEmpty($version))) { $request += "/" + $version }
You can also use !
as an alternative to -not
.
You don't necessarily have to use the [string]:: prefix. This works in the same way:
if ($version) { $request += "/" + $version }
A variable that is null or empty string evaluates to false.
As in many other programming and scripting languages you can do so by adding !
in front of the condition
if (![string]::IsNullOrEmpty($version)) { $request += "/" + $version }
Comments
Post a Comment