6 Aralık 2012, PERŞEMBE
Nasıl bir dize null veya boş olup olmadığını kontrol edin PowerShell miyim?
Eğer bir dize null veya boş olup olmadığını kontrol etmek amacıyla inşa edilmiş-IsNullOrEmpty
-gibi bir işlevi var, powershell'de?
Şimdiye kadar bulamadım ve eğer bir yerleşik bir yolu varsa, bunun için bir fonksiyon yazmak istemiyorum.
CEVAP
6 Aralık 2012, PERŞEMBE
Siz bu çok zor hale getiriyor. PowerShell bu oldukça zarif örneğin kolları:
> $str1 = $null
> if ($str1) { 'not empty' } else { 'empty' }
empty
> $str2 = ''
> if ($str2) { 'not empty' } else { 'empty' }
empty
> $str3 = ' '
> if ($str3) { 'not empty' } else { 'empty' }
not empty
> $str4 = 'asdf'
> if ($str4) { 'not empty' } else { 'empty' }
not empty
> if ($str1 -and $str2) { 'neither empty' } else { 'one or both empty' }
one or both empty
> if ($str3 -and $str4) { 'neither empty' } else { 'one or both empty' }
neither empty
Bunu Paylaş:
Eğer bir dize null olup olmadığını kon...
Nasıl bir sütun boş veya null olup olm...
Nasıl bir dize bir sayı (yüzen) olup o...
Değişken olup olmadığını kontrol edin....
Java, bir dize null ve boş olup olmadı...