Powershell为什么说System.Drawing.Point不包含名为split的方法。

时间:2018-07-03 14:42:30

标签: string powershell split

即使代码确实运行并成功执行了我想要的操作,下面的代码也会引发以下错误。

  

方法调用失败,因为[System.Drawing.Point]没有   包含一个名为“ Split”的方法。

我正在尝试分割以下字符串以仅提取Y坐标。

{X = 695,Y = 665}

代码在下面。

$Y_Axis = $postTopScroll2.Split('=')[-1]     
write-host $Y_Axis # 665}

$Y_Axis2 = $postTopScroll2.Split('}')[0]     
Write-Host $Y_Axis2 # 665

我在网上找不到任何信息。

1 个答案:

答案 0 :(得分:0)

似乎基于您的帖子,$ postTopScroll2是System.Drawing.Point https://msdn.microsoft.com/en-us/library/system.drawing.point(v=vs.110).aspx

您似乎不需要进行任何拆分,因为它已经具有X和Y的属性

[System.Drawing.Point]$postTopScroll2 = [System.Drawing.Point]::new(11,99)
$Y_Axis = $postTopScroll2.y
write-output $Y_Axis

返回 99

相关问题