PowerShell $null is not null any more when calling into C# code
问题 In PowerShell one can define C# code and execute it. Passing in $null into the following simplest function shows that not null gets passed into the function Add-Type -TypeDefinition @" public static class foo { public static void fooo(string a) { if(a!=null) { System.Console.WriteLine("Not Null. Is '" + a + "'"); } } } "@ -Language CSharp Calling it as follows leads to the output Not Null. Is ''. This shows that $null was not null in C#. Methods like 'IsNullOrEmpty' or 'IsNullOrWhiteSpace'