Can LINQ be used in PowerShell?

前端 未结 5 1011
我寻月下人不归
我寻月下人不归 2020-12-13 23:43

I am trying to use LINQ in PowerShell. It seems like this should be entirely possible since PowerShell is built on top of the .NET Framework, but I cannot get it to work.

5条回答
  •  [愿得一人]
    2020-12-13 23:55

    There is a simple way to make Linq chaining fluent, by setting a using statement to the Linq namespace, Then you can call the where function directly, no need to call the static Where function.

    using namespace System.Linq
    $b.Where({$_ -gt 0})
    

    $b is an array of bytes, and I want to get all bytes that are greater than 0.

    Works perfect.

提交回复
热议问题