Object[]
should cast to IEnumerable[<>]
#16538
Labels
Issue-Enhancement
the issue is more of a feature request than a bug
Up-for-Grabs
Up-for-grabs issues are not high priorities, and may be opportunities for external contributors
WG-Engine
core PowerShell engine, interpreter, and runtime
Prerequisites
Steps to reproduce
I am not quiet sure about this, but I would expect PowerShell to be able to cast (CanConvertTo) an object array (
Object[]
) to a specificIEnumerable
. The issue occurred to me when I was trying to create anInvariantCultureIgnoreCase
HashSet
and immediately populate it in a single statement:Expected behavior
Actual behavior
MethodException: Cannot find an overload for "new" and the argument count: "2".
Environment data
Workarround
To workaround this you will need specify the array item type (
[string[]]
):Related
This is probably related to the fact that I can't directly cast an
object[]
to a specific enumerable either:But this (rather WET) statement works:
Related issues
#16002
IEnumerable -property values should enumerate#16003
Accelerate HashSetThe text was updated successfully, but these errors were encountered: