gpt4 book ai didi

powershell - PowerShell 是否支持 PS 模块中的私有(private)静态变量

转载 作者:行者123 更新时间:2023-12-05 05:22:17 27 4
gpt4 key购买 nike

PowerShell 是否支持 PowerShell 模块中的私有(private)静态变量(如 C# 中的私有(private)静态变量)?如果是这样,我需要一个“特殊”语法吗?

最佳答案

你应该看看 about_Scopes documentation .

有一个脚本作用域:

 Script: 
The scope that is created while a script file runs. Only
the commands in the script run in the script scope. To
the commands in a script, the script scope is the local
scope.

也值得一读——无范围限制:

Modules:
You can use a Windows PowerShell module to share and deliver
Windows PowerShell tools. A module is a unit that can contain
cmdlets, scripts, functions, variables, aliases, and other useful
items. Unless explicitly defined, the items in a module are not
accessible outside the module. Therefore, you can add the module to
your session and use the public items without worrying that the
other items might override the cmdlets, scripts, functions, and other
items in your session.


The privacy of a module behaves like a scope, but adding a module
to a session does not change the scope. And, the module does not have
its own scope, although the scripts in the module, like all Windows
PowerShell scripts, do have their own scope.

关于powershell - PowerShell 是否支持 PS 模块中的私有(private)静态变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40838512/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com