使用“from”的示例:和“数据”;关键词?

发布于 2024-09-11 18:53:52 字数 1077 浏览 4 评论 0原文

感谢 这篇文章中,我能够想出一个脚本来对 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

我正在查看列表,我了解到 classdefineusingvar 是保留关键字,但出于好奇,是否有人有使用 from的示例>数据关键字?我似乎找不到任何东西。

谢谢

编辑

使用from关键字会导致这样的结果:

PS H:\> from
The 'from' keyword is not supported in this version of the language.
At line:1 char:1

帮助主题about_language_keywords也很有用。

Thanks to this article, I was able to come up with a script which sorts and displays the keywords PowerShell provides:

$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

I was looking at the list and I understand that class, define, using and var are reserved keywords, but just out of curiosity, does anybody have an example using the from and data keywords? I can't seem to find anything.

Thanks

EDIT

Use of the from keyword results in this:

PS H:\> from
The 'from' keyword is not supported in this version of the language.
At line:1 char:1

The help topic about_language_keywords is also useful.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

拒绝两难 2024-09-18 18:53:57

帮助主题about_Data_Sections解释了data关键字,run:

help about_Data_Sections

至于from关键字,我认为它只是保留的,尚未使用。

The help topic about_Data_Sections explains the data keyword, run:

help about_Data_Sections

As for the from keyword, I think it is just reserved and not yet used.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文