Author Posts

March 21, 2018 at 2:55 pm

How does one create a HashSet with a ctor arg of StringComparison.OrdinalIgnorecase?

PS M:\> New-Object -TypeName System.Collections.Generic.HashSet[string] -ArgumentList @([StringComparison]::OrdinalIgnorecase)
New-Object : Multiple ambiguous overloads found for "HashSet`1" and the argument count: "1".
At line:1 char:1
+ New-Object -TypeName System.Collections.Generic.HashSet[string] -ArgumentList @( ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [New-Object], MethodException
    + FullyQualifiedErrorId : ConstructorInvokedThrowException,Microsoft.PowerShell.Commands.NewObjectCommand

March 22, 2018 at 1:53 pm

Might be wrong (don't read MSDN all day 🙂 ) but if I understand it correctly StringComparison is a enum/property to tell string methods how to compare strings.
It's not a constructor.

The class and constructor is StringComparer.

https://msdn.microsoft.com/en-us/library/system.stringcomparer(v=vs.110).aspx

March 24, 2018 at 8:58 pm

I tried to reply when you posted your response (thanks for doing that so quickly) but the broken web host dos prevention locked me out...

I can't believe I fat fingered that without noticing, I actually fired up VS and whipped up a simple invocation as I thought I wasn't doing something right. I still failed to notice my console repro was differnt:)

Thanks for the nudge!