感谢this文章,我能够想出一个脚本来排序和显示 PowerShell 提供的关键字:
$bindingFlags =
[System.Reflection.BindingFlags]::NonPublic -bor
[System.Reflection.BindingFlags]::Static -bor
[System.Reflection.BindingFlags]::GetField
$keywordTokenReader = [System.Type]::GetType("System.Management.Automation.KeywordTokenReader")
$keywords = $keywordTokenReader.InvokeMember("_keywordTokens", $bindingFlags, $null, $null, $null)
$keywords.GetEnumerator() | Sort-Object -Property Name
我正在查看列表,我了解到 class
、define
、using
和 var
是保留的关键字,但出于好奇,有人有使用 from
和 data
关键字的示例吗?我似乎找不到任何东西。
谢谢
编辑
使用 from
关键字会导致:
PS H:\> from
The 'from' keyword is not supported in this version of the language.
At line:1 char:1
帮助主题 about_language_keywords
也很有用。
最佳答案
帮助主题about_Data_Sections
解释了data
关键字,运行:
help about_Data_Sections
至于from
关键字,我觉得只是保留的,还没有使用。
关于powershell - 使用 'from' 和 'data' 关键字的示例?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3334860/