Is there a difference between using Collections.Generic.List[Int] and Collections.Generic.List``1[Int] in PowerShell?

Viewed 46

Question says it all. Is there a difference between Collections.Generic.List[Int] and Collections.Generic.List``1[Int] in PowerShell and if so, what are those differences?

For Example if i use $list = New-Object Collections.Generic.List``1[Int]

What is the meaning behind the "``" and "1"?

If this Question was already asked then I apologize. I couldn't find it.

1 Answers

They are the same:

PS> [Collections.Generic.List[Int]] -eq [Collections.Generic.List``1[Int]]                                
True

The latter is just how the type is actually named in the .NET Standard library. Generic types all have a suffix with the backtick and the number of generic type parameters. Most languages hide this from the programmer, though. PowerShell gained those unsuffixed generic types only in a later version, so both variants still work, I guess.

Related