16 June 2014

Test for Null, empty or wite-space characters


$a = $null
$b = ''
$c = ' '

"`$a contains null: " + ([string]::IsNullOrWhiteSpace($a))
"`$b is empty: " + ([string]::IsNullOrWhiteSpace($b))
"`$c has one space: " + ([string]::IsNullOrWhiteSpace($c))

$a contains null: True
$b is empty: True
$c has one space: True


more info about IsNullOrWhiteSpace method

No comments:

Post a Comment