What is the Linq.First equivalent in PowerShell?

后端 未结 4 998
孤城傲影
孤城傲影 2021-02-01 12:44

The snippet below detects from a list of files which of them is a Directory on Ftp

as C# it will be like below

var files = new List(){\"App         


        
4条回答
  •  深忆病人
    2021-02-01 13:45

    Doug Finke produced a great video ( only 7 mins ) about converting C# to Powershell http://dougfinke.com/video/CSharpToPowerShell.html

    Roberts example is very good indeed, though comma delimiting will implicitly be treated as an array

    the shortest way of doing it would be to put it all into a single pipeline :

    $dir = "App_Data", "bin", "Content" | % { if("drwxr-xr-x 1 ftp ftp              0 Mar 18 22:41 App_Data".EndsWith($_)) { $_ } } | select -first 1
    

提交回复
热议问题