PowerShell $null is not null any more when calling into C# code PowerShell $null is not null any more when calling into C# code powershell powershell

PowerShell $null is not null any more when calling into C# code


Evidently the solution is "don't pass $null to a [String] parameter if you want a $null [String]". There is a special [NullString] class that should be used instead.

PS > [foo]::fooo($Null)Not Null. Is ''PS > [foo]::fooo([NullString]::Value)PS >

I can't find any mentions of the need to use [NullString] in the PowerShell documentation, nor does the source code for the NullString class include any comments explaining its purpose.