Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/csharp-4.0/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
通过powershell中值大于10的子字符串(10,20)错误从变量中拾取数据_Powershell - Fatal编程技术网

通过powershell中值大于10的子字符串(10,20)错误从变量中拾取数据

通过powershell中值大于10的子字符串(10,20)错误从变量中拾取数据,powershell,Powershell,为什么我不能从“$final.Substring(10,23)”和“$final.Substring(24,31)”中获取数据? 看起来只要我超过9的范围,它就会失败 我得到的错误如下 使用“2”参数调用“Substring”时出现异常:“索引和长度” 必须引用字符串中的位置。参数名称:length“At 行:34字符:1 +$thirdOct=$final.Substring(10,23) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +CategoryInfo:

为什么我不能从“$final.Substring(10,23)”和“$final.Substring(24,31)”中获取数据? 看起来只要我超过9的范围,它就会失败

我得到的错误如下

使用“2”参数调用“Substring”时出现异常:“索引和长度” 必须引用字符串中的位置。参数名称:length“At 行:34字符:1 +$thirdOct=$final.Substring(10,23) + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +CategoryInfo:NotSpecified:(:)[],MethodInvocationException +FullyQualifiedErrorId:ArgumentOutOfRangeException


第二个参数是
length
,而不是
endindex

$final.Substring.OverloadDefinitions
string Substring(int startIndex)
string Substring(int startIndex, int length)

PS-ADMIN > $final.Length
32

PS-ADMIN > 10+23
33

子字符串的第二个参数的名称是什么。。。我猜已经晚了,第二个参数只是范围,而不是端点!
$final.Substring.OverloadDefinitions
string Substring(int startIndex)
string Substring(int startIndex, int length)

PS-ADMIN > $final.Length
32

PS-ADMIN > 10+23
33