Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > PowerShell

Vista - Re: Multidimensional Arrays

Reply
 
Old 04-02-2009   #1 (permalink)
Vadims Podans [MVP]


 
 

Re: Multidimensional Arrays

[vPodans] $a = (1,2),(3,4)
[vPodans] $a += ,(5,6)
[vPodans] $a[0]
1
2
[vPodans] $a[1]
3
4
[vPodans] $a[2]
5
6
[vPodans] $a[2][0]
5
[vPodans] $a[2][1]
6

enjoy!
--
WBR, Vadims Podans
MVP: PowerShell
PowerShell blog - www.sysadmins.lv

"Jo" <Jo@xxxxxx> rakstīja ziņojumā
"news:6B8C9E87-4EF3-4AB6-A869-D743CA8804BE@xxxxxx"...
Quote:

> Hi,
>
> here is an example from
> http://blogs.msdn.com/powershell/arc...wershell.aspx:
>
> $a = (1,2),(3,4) # array of two elements, each of which is a two element
> array
> $a += ,(5,6) # add another element which is an array of two element.
>
> The blog entry also shows how to access the array elements:
>
> PS (61) > $a[0]
> 1
> 2
>
> PS (62) > $a[1]
> 3
> 4
>
> PS (63) > $a[2]
> 5
> 6
>
> But how would you access an array element within the array, i.e. element 6
> only?
>
> Thanks,
> Jo

My System SpecsSystem Spec
Old 04-02-2009   #2 (permalink)
Jo


 
 

RE: Multidimensional Arrays

"Jo" wrote:
Quote:

> Hi,
>
> here is an example from
> http://blogs.msdn.com/powershell/arc...wershell.aspx:
>
> $a = (1,2),(3,4) # array of two elements, each of which is a two element
> array
> $a += ,(5,6) # add another element which is an array of two element.
>
> The blog entry also shows how to access the array elements:
>
> PS (61) > $a[0]
> 1
> 2
>
> PS (62) > $a[1]
> 3
> 4
>
> PS (63) > $a[2]
> 5
> 6
>
> But how would you access an array element within the array, i.e. element 6
> only?
Another question: Anybody has a good reference (blog, web site, book,
whatever) about dealing with multidimensional arrays in PowerShell?

Thanks,
Jo
My System SpecsSystem Spec
Old 04-02-2009   #3 (permalink)
Jo


 
 

Re: Multidimensional Arrays

"Vadims Podans [MVP]" wrote:
Quote:

> [vPodans] $a = (1,2),(3,4)
> [vPodans] $a += ,(5,6)
> [vPodans] $a[0]
> 1
> 2
> [vPodans] $a[1]
> 3
> 4
> [vPodans] $a[2]
> 5
> 6
> [vPodans] $a[2][0]
> 5
> [vPodans] $a[2][1]
> 6
Ups, that was simple, tried it slightly different. Thanks!

Joachim
My System SpecsSystem Spec
Old 04-02-2009   #4 (permalink)
Vadims Podans [MVP]


 
 

Re: Multidimensional Arrays

check this:
http://www.techotopia.com/index.php/...PowerShell_1.0
--
WBR, Vadims Podans
MVP: PowerShell
PowerShell blog - www.sysadmins.lv

"Jo" <Jo@xxxxxx> rakstīja ziņojumā
"news:8935F77D-21C2-4FA0-9718-654DA66A0581@xxxxxx"...
Quote:

> "Jo" wrote:
>
Quote:

>> Hi,
>>
>> here is an example from
>> http://blogs.msdn.com/powershell/arc...wershell.aspx:
>>
>> $a = (1,2),(3,4) # array of two elements, each of which is a two element
>> array
>> $a += ,(5,6) # add another element which is an array of two element.
>>
>> The blog entry also shows how to access the array elements:
>>
>> PS (61) > $a[0]
>> 1
>> 2
>>
>> PS (62) > $a[1]
>> 3
>> 4
>>
>> PS (63) > $a[2]
>> 5
>> 6
>>
>> But how would you access an array element within the array, i.e. element
>> 6
>> only?
>
> Another question: Anybody has a good reference (blog, web site, book,
> whatever) about dealing with multidimensional arrays in PowerShell?
>
> Thanks,
> Jo
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Is there a simple way to search a multidimensional array? PowerShell
I NEED HELP creating a multidimensional array from a csv file VB Script
Multidimensional arrays PowerShell
multidimensional array initialization PowerShell
Bug with multidimensional arrays PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46