Last active
November 12, 2019 16:11
-
-
Save altrive/c9b39f5bc8dcc8791274 to your computer and use it in GitHub Desktop.
PowerShell v5 'using namespace' syntax test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Require -Version 5.0 | |
# using statement must appear before any other statements in a script. | |
# other using types(Assembly/Command/Module/Type) is not supported yet? | |
# [Enum]::GetNames('System.Management.Automation.Language.UsingStatementKind') | |
using namespace System.Diagnostics | |
using namespace System.Linq | |
function Main | |
{ | |
Set-StrictMode -Version Latest | |
$ErrorActionPreference = "Stop" | |
#Using System.Diagnostics.Stopwatch | |
$sw = [Stopwatch]::StartNew() | |
sleep -Milliseconds 100 | |
Write-Host ('Elapsed: {0} [ms]' -f $sw.ElapsedMilliseconds) | |
#Using System.Linq methods | |
[int[]] $array = 1..10 | |
[Enumerable]::Where($array, [Func[[int], [bool]]]{ param ($p) $p % 2 -eq 0}) | |
} | |
Main |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment