【发布时间】:2014-06-11 13:21:59
【问题描述】:
这是我的代码,
$fourCount = 0
$rowCount = 0
foreach($row in $ResultsTable){
if ($row.'RowType' -eq 6) {
if ($fourCount -gt 0) {
#Sort-Object {$row.'CheckDate'} - descending
$remainAmount = $currentAmount - $checkAmount
$ResultsTable.Rows[$rowCount - 1].'Final' = $remainAmount
$currentAmount = @()
$fourCount = 0
$remainAmount = 0
}
$checkAmount = [int]$row.'amount'
$rowCount = $rowCount + 1
} elseif ($row.'RowType' -eq 4) {
if($row.'current'.Length -eq $NULL) {
Continue
} else {
$currentAmount += [int]$row.'current'
$rowCount = $rowCount + 1
$fourCount++
}
} else {
Continue
}
}
我在运行代码时遇到的问题是
方法调用失败,因为 [System.Object[]] 不包含 名为“op_Subtraction”的方法。
$remainAmount = $currentAmount - FullyQualifiedErrorId : MethodNotFound
根据我的阅读,我将所有内容都转换为 int,但它仍然无法运行。谁能告诉我为什么?
【问题讨论】:
标签: string powershell int