Skip to content

convert an array of strings to a single string

2011/04/10

I got an array of strings that I had to join to a single string. One solution is to put the array into quotation marks

Example:

$stringArray = "a,b;c.D" -split { [Char]::IsPunctuation($_)}
$stringArray
a
b
c
D
$oneString = "$stringArray"
$oneString.GetType()
IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String                                   System.Object
$stringArray.GetType()
IsPublic IsSerial Name                                     BaseType
-------- -------- ----                                     --------
True     True     String[]                                 System.Array
$oneString
a b c D

Following code

[char] | Get-Member -Static -MemberType Method -Name is*

shows all the different methods that can be used to categorize chars. (source is this article on powershell.com)

Advertisements
Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: