Converting from C# to Powershell syntax

powershell

Solution

Brackets = access to a type

double colons = access to a static member of a type : [MyType] return a Type instance

ex:

c:> [System.Int32]

IsPublic IsSerial Name BaseType

-------- -------- ---- --------

True True Int32 System.ValueType

using the dot notation would only give you access to instance members of the Type instance (reflection related methods for most)...

c:\> [System.Int32].Parse("3")

Method call failed because [System.Runtype] does not have any "Parse" member

c:\> [System.Int32].AssemblyQualifiedName

System.Int32, mscorlib, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089

so :: is the way to access static members of a Class

c:\> [System.Int32]::Parse("3")
3

Problem

In C# I can use the method `Console.Error.WriteLine`. This doesn't work in Powershell, instead I must write ``` [Console]::Error.WriteLine ``` Why square brackets, why the double colons? ps. To be clear, I'm not interested in logging, I want to understand the syntax about types and objects and methods

Original source