O R G A N I C / F E R T I L I Z E R: powershell: an array of alphabets

Jun 25, 2013

powershell: an array of alphabets

i wish i could remember where i found this particular gem. as you know, it's crazy easy to create an array of values if they're integers such as:
[1] {C:\temp} > $a = 1..10[2] {C:\temp} > $a12345678910
but what about when you want an array of alphabetical characters like a through z? it's not as simple as defining the range as a..z. instead, you have to call the char type as shown below:

[7] {C:\temp} > $alphabet = [char[]]([char]'a'..[char]'z')
[8] {C:\temp} > $alphabet
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z