- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我见过一个看起来像这样的函数:
function
{
[CmdletBinding()]
[OutputType([Boolean])]
param (
[bool] $param
}
# ...
}
这里Boolean
和bool
有什么区别?
最佳答案
[bool]
是一个 powershell type accelerator .
我使用的是 powershell 7。如果它在某个地方有官方文档,我找不到它(除了 Windows Powershell in Action,像往常一样)。
[psobject].Assembly.GetType("System.Management.Automation.TypeAccelerators")::get
Key Value
--- -----
Alias System.Management.Automation.AliasAttribute
AllowEmptyCollection System.Management.Automation.AllowEmptyCollectionAttribute
AllowEmptyString System.Management.Automation.AllowEmptyStringAttribute
AllowNull System.Management.Automation.AllowNullAttribute
ArgumentCompleter System.Management.Automation.ArgumentCompleterAttribute
ArgumentCompletions System.Management.Automation.ArgumentCompletionsAttribute
array System.Array
bool System.Boolean
byte System.Byte
char System.Char
CmdletBinding System.Management.Automation.CmdletBindingAttribute
datetime System.DateTime
decimal System.Decimal
double System.Double
DscResource System.Management.Automation.DscResourceAttribute
ExperimentAction System.Management.Automation.ExperimentAction
Experimental System.Management.Automation.ExperimentalAttribute
ExperimentalFeature System.Management.Automation.ExperimentalFeature
float System.Single
single System.Single
guid System.Guid
hashtable System.Collections.Hashtable
int System.Int32
int32 System.Int32
short System.Int16
int16 System.Int16
long System.Int64
int64 System.Int64
ciminstance Microsoft.Management.Infrastructure.CimInstance
cimclass Microsoft.Management.Infrastructure.CimClass
cimtype Microsoft.Management.Infrastructure.CimType
cimconverter Microsoft.Management.Infrastructure.CimConverter
IPEndpoint System.Net.IPEndPoint
NullString System.Management.Automation.Language.NullString
OutputType System.Management.Automation.OutputTypeAttribute
ObjectSecurity System.Security.AccessControl.ObjectSecurity
Parameter System.Management.Automation.ParameterAttribute
PhysicalAddress System.Net.NetworkInformation.PhysicalAddress
pscredential System.Management.Automation.PSCredential
PSDefaultValue System.Management.Automation.PSDefaultValueAttribute
pslistmodifier System.Management.Automation.PSListModifier
psobject System.Management.Automation.PSObject
pscustomobject System.Management.Automation.PSObject
psprimitivedictionary System.Management.Automation.PSPrimitiveDictionary
ref System.Management.Automation.PSReference
PSTypeNameAttribute System.Management.Automation.PSTypeNameAttribute
regex System.Text.RegularExpressions.Regex
DscProperty System.Management.Automation.DscPropertyAttribute
sbyte System.SByte
string System.String
SupportsWildcards System.Management.Automation.SupportsWildcardsAttribute
switch System.Management.Automation.SwitchParameter
cultureinfo System.Globalization.CultureInfo
bigint System.Numerics.BigInteger
securestring System.Security.SecureString
timespan System.TimeSpan
ushort System.UInt16
uint16 System.UInt16
uint System.UInt32
uint32 System.UInt32
ulong System.UInt64
uint64 System.UInt64
uri System.Uri
ValidateCount System.Management.Automation.ValidateCountAttribute
ValidateDrive System.Management.Automation.ValidateDriveAttribute
ValidateLength System.Management.Automation.ValidateLengthAttribute
ValidateNotNull System.Management.Automation.ValidateNotNullAttribute
ValidateNotNullOrEmpty System.Management.Automation.ValidateNotNullOrEmptyAttribute
ValidatePattern System.Management.Automation.ValidatePatternAttribute
ValidateRange System.Management.Automation.ValidateRangeAttribute
ValidateScript System.Management.Automation.ValidateScriptAttribute
ValidateSet System.Management.Automation.ValidateSetAttribute
ValidateTrustedData System.Management.Automation.ValidateTrustedDataAttribute
ValidateUserDrive System.Management.Automation.ValidateUserDriveAttribute
version System.Version
void System.Void
ipaddress System.Net.IPAddress
DscLocalConfigurationManager System.Management.Automation.DscLocalConfigurationManagerAttribute
WildcardPattern System.Management.Automation.WildcardPattern
X509Certificate System.Security.Cryptography.X509Certificates.X509Certificate
X500DistinguishedName System.Security.Cryptography.X509Certificates.X500DistinguishedName
xml System.Xml.XmlDocument
CimSession Microsoft.Management.Infrastructure.CimSession
mailaddress System.Net.Mail.MailAddress
semver System.Management.Automation.SemanticVersion
scriptblock System.Management.Automation.ScriptBlock
pspropertyexpression Microsoft.PowerShell.Commands.PSPropertyExpression
psvariable System.Management.Automation.PSVariable
type System.Type
psmoduleinfo System.Management.Automation.PSModuleInfo
powershell System.Management.Automation.PowerShell
runspacefactory System.Management.Automation.Runspaces.RunspaceFactory
runspace System.Management.Automation.Runspaces.Runspace
initialsessionstate System.Management.Automation.Runspaces.InitialSessionState
psscriptmethod System.Management.Automation.PSScriptMethod
psscriptproperty System.Management.Automation.PSScriptProperty
psnoteproperty System.Management.Automation.PSNoteProperty
psaliasproperty System.Management.Automation.PSAliasProperty
psvariableproperty System.Management.Automation.PSVa
自己制作:
$Accelerators = [PowerShell].Assembly.GetType("System.Management.Automation.TypeAccelerators")
$Accelerators::Add('dt','system.datetime')
[dt]'1:00'
Saturday, February 22, 2020 1:00:00 AM
关于powershell - boolean和bool的区别?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60333603/
我正在尝试从文本文件构建 boolean 值[][]。我正在读取每个字符,存储在 ArrayList 中(1 为真,0 为假)。我试过 ArrayList,但出现编译错误,意外元素。因此,我构建了一个
我想知道编程语言中的运算符优先级是否取决于实现,还是所有语言都遵循固定的规则。并且,如果可能的话,您可以先排序以下具有最高优先级的运算符吗:AND,OR,NOT,XOR。 最佳答案 我在Google上
这是同样的事情,对吗?还是有细微的差别?我只是想确保我没有误解任何事情。 最佳答案 通过简单地将 AND 替换为 OR 以及将 OR 替换为 AND 即可生成 boolean 对偶。补码本身不受影响,
我想这对于大多数优秀的程序员来说是微不足道的,但我已经习惯使用 true 进行编程。和 false 2、当我遇到0和1的时候,我永远记不住哪一个是真的,哪一个是假的。 有什么建议? 1好:I mean
我正在尝试将此 Java 示例转换为 Kotlin: Gson gson = new GsonBuilder() .registerTypeAdapter(Boolean.class,
下面的代码打印 true。 public static void main(String[] args) { Boolean test = false; test =
我在处理应该导致在 iReport 中显示或隐藏 strip 的表达式时遇到困难。 这些是我拥有的变量: Integer mainGroupInt = Integer.valueOf(5); Inte
以下编码错误可能是因为 Boolean equals(Object) 方法不需要 boolean/Boolean 参数: private void foo() { Boolean isSome
我想简化一个 boolean 表达式。 表达式是这样的 X1 xor (X2 || X3 && X4 || x5) 如何使用 boolean 代数规则简化此表达式。 而且我想将上面的 boolean
我正在使用一些工具,它可以确定特定事务是否成功的唯一方法是它是否通过了各种检查。但是,它的方式有限制,一次只能做一次检查,而且必须是顺序的。一切都必须从左到右计算。 例如, A || C && D 它
在大多数编程语言中,1和 0可以用来代替 True和 False .然而,根据我的经验,整数似乎总是更容易使用。 以下是我的意思的一些示例: if x is True: x = False else:
我有一个 boolean 方程,想简化它。帮忙解决一下。 bool needLoad = isA || (!isA && !isB); 之后我使用 if (needLoad){ if (
我认为这始终是正确的 x || (x && y) 相当于 x 如果是这样,那条法律叫什么?我什至不知道如何通过 Google 搜索该信息。 最佳答案 它被称为 Redundancy Law . A +
是否有任何现有的方法或功能模块可以有效地翻转 boolean 值? 如果我必须定义自己的实用方法,我想出了一个简单的实现,但我想知道这是否是最有效的方法: IF iv_bool = abap_true
我有这个表达式:X'YZ'+X'YZ+XY'Z'+XYZ'+XYZ('表示不是)我知道答案是 Y+XZ' 但我陷入了最后一部分。有人可以帮我吗? 这是我到目前为止得到的: X'YZ' + X'YZ +
openCL 支持 boolean 变量吗?我目前正在使用 JOCL (java) 编写我的 openCL 调用代码,但我没有看到任何有关 boolean 值的信息。 最佳答案 tl;dr:是的,但您
我认为这是对的 x || (x && y) 相当于 x 如果是这样,那条法律叫什么?我什至不确定我会如何使用 Google。 最佳答案 它叫做 Redundancy Law . A + A·B = A
我有一些功能,例如 (A and ( B or c)) or (D and E and (F or H or R or P ))) 我想将该函数转换为仅包含 and 操作的函数(当然如果可能的话)我发
我参加了编程面试,由 3 名面试官组成,每人 45 分钟。虽然前两位面试官给了我 2-3 个简短的编码问题(即反向链表、使用 rand(5) 实现 rand(7) 等),但第三位面试官使用了整个时间段
如果我只想检查某事是否不可能(即,我不会使用类似 if(possible) 的东西),我应该将 boolean 值命名为 notPossible并使用 if(notPossible)或者我应该命名它p
我是一名优秀的程序员,十分优秀!