Reputation: 72171
Lets say I want to do something like this:
$string = 'arbitrary string' # << is random
$string = ($string + 'randomstring').Substring(0, [math]::Min(20, $string.lenght) # < doesn't work properly
How do I get current length of $string
, when it is not yet assigned?
Upvotes: 4
Views: 43
Reputation: 58971
Just assign the string using +=
.
$string = 'arbitrary string' # << is random
$string = ($string += 'randomstring').Substring(0, [math]::MIN(20, $string.Length)) #
Upvotes: 3