![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
![]() |
| |
| | #1 (permalink) |
| | How to Create Collection Generic Class using new-object For example in C# it is like using System.Net; System.Collections.ObjectModel.Collection<IPAddress> IPs = new System.Collections.ObjectModel.Collection<IPAddress>(); How to do it in powershell? It is not working: $test = new-object System.Collections.ObjectModel.Collection '1[System.Net.IPAdress] TonyDesweet http://mshforfun.blogspot.com/ |
My System Specs![]() |
| | #2 (permalink) |
| | Re: How to Create Collection Generic Class using new-object On Fri, 30 Jun 2006 12:21:01 -0700, TonyDesweet <TonyDesweet@discussions.microsoft.com> wrote: >[System.Net.IPAdress] It may not be the only problem but you have a typo in your class name. It should, I think, be IPAddress. Andrew Watt MVP |
My System Specs![]() |
| | #3 (permalink) |
| | Re: How to Create Collection Generic Class using new-object $test = new-object System.Collections.ObjectModel.Collection '1[System.Net.IPAdrress] still not working "Andrew Watt [MVP]" wrote: > On Fri, 30 Jun 2006 12:21:01 -0700, TonyDesweet > <TonyDesweet@discussions.microsoft.com> wrote: > > >[System.Net.IPAdress] > > It may not be the only problem but you have a typo in your class name. > It should, I think, be IPAddress. > > Andrew Watt MVP > |
My System Specs![]() |
| | #4 (permalink) |
| | Re: How to Create Collection Generic Class using new-object opps, another typo. $test = new-object System.Collections.ObjectModel.Collection '1[System.Net.IPAddress] still not working > > $test = new-object System.Collections.ObjectModel.Collection > '1[System.Net.IPAdrress] > > still not working > > "Andrew Watt [MVP]" wrote: > > > On Fri, 30 Jun 2006 12:21:01 -0700, TonyDesweet > > <TonyDesweet@discussions.microsoft.com> wrote: > > > > >[System.Net.IPAdress] > > > > It may not be the only problem but you have a typo in your class name. > > It should, I think, be IPAddress. > > > > Andrew Watt MVP > > |
My System Specs![]() |
| | #5 (permalink) |
| | Re: How to Create Collection Generic Class using new-object The following works, but it is insane. I will open an internal bug to track this issue. PS C:\monad> $A=new-object "System.Collections.ObjectModel.Collection``1[[System.Net.IPAddress, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" PS C:\monad> $A.gettype() IsPublic IsSerial Name BaseType -------- -------- ---- -------- True True Collection`1 System.Object -- Wei Wu [MSFT] Windows PowerShell Team Microsoft Corporation This posting is provided "AS IS" with no warranties, and confers no rights. "TonyDesweet" <TonyDesweet@discussions.microsoft.com> wrote in message news 80F8AA4-4D81-4B9E-AACA-7DEC51AE5D49@microsoft.com...> > opps, another typo. > > $test = new-object System.Collections.ObjectModel.Collection > '1[System.Net.IPAddress] > > still not working > > >> >> $test = new-object System.Collections.ObjectModel.Collection >> '1[System.Net.IPAdrress] >> >> still not working >> >> "Andrew Watt [MVP]" wrote: >> >> > On Fri, 30 Jun 2006 12:21:01 -0700, TonyDesweet >> > <TonyDesweet@discussions.microsoft.com> wrote: >> > >> > >[System.Net.IPAdress] >> > >> > It may not be the only problem but you have a typo in your class name. >> > It should, I think, be IPAddress. >> > >> > Andrew Watt MVP >> > |
My System Specs![]() |
| | #6 (permalink) |
| | Re: How to Create Collection Generic Class using new-object "Wei Wu [MSFT]" <wwu@microsoft.com> wrote in message news:u17DzdInGHA.4144@TK2MSFTNGP05.phx.gbl... > The following works, but it is insane. I will open an internal bug to > track this issue. Wouldn't a native generic syntax for PowerShell be nice? Say something like: $a = new-object Collections.Dictionary[[string], [xml]] or $a = new-object Collections.Dictionary[string, xml] -- Keith |
My System Specs![]() |
| | #7 (permalink) |
| | Re: How to Create Collection Generic Class using new-object I see. It requires strong name. "Wei Wu [MSFT]" wrote: > The following works, but it is insane. I will open an internal bug to track > this issue. > PS C:\monad> $A=new-object > "System.Collections.ObjectModel.Collection``1[[System.Net.IPAddress, System, > Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089]]" > PS C:\monad> $A.gettype() > > IsPublic IsSerial Name BaseType > -------- -------- ---- -------- > True True Collection`1 System.Object > > > > -- > Wei Wu [MSFT] > Windows PowerShell Team > Microsoft Corporation > This posting is provided "AS IS" with no warranties, and confers no rights. > > "TonyDesweet" <TonyDesweet@discussions.microsoft.com> wrote in message > news 80F8AA4-4D81-4B9E-AACA-7DEC51AE5D49@microsoft.com...> > > > opps, another typo. > > > > $test = new-object System.Collections.ObjectModel.Collection > > '1[System.Net.IPAddress] > > > > still not working > > > > > >> > >> $test = new-object System.Collections.ObjectModel.Collection > >> '1[System.Net.IPAdrress] > >> > >> still not working > >> > >> "Andrew Watt [MVP]" wrote: > >> > >> > On Fri, 30 Jun 2006 12:21:01 -0700, TonyDesweet > >> > <TonyDesweet@discussions.microsoft.com> wrote: > >> > > >> > >[System.Net.IPAdress] > >> > > >> > It may not be the only problem but you have a typo in your class name. > >> > It should, I think, be IPAddress. > >> > > >> > Andrew Watt MVP > >> > > > > |
My System Specs![]() |
![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Reflection with Generic Collection types | .NET General | |||
| Object not a collection error | VB Script | |||
| Generic Class: Passing Data Type to Placeholder | .NET General | |||
| object not a collection | VB Script | |||
| Re: Unable to cast COM object of type 'ADODB.RecordsetClass' to class type 'System.Object[]' | .NET General | |||