About_对象的功能

Learning about methods

To find definitions of the methods of an object, go to help topic for the
object type and look for its methods page. For example, the following page
describes the methods of process objects System.Diagnostics.Process.

To determine the arguments of a method, review the method definition, which
is like the syntax diagram of a PowerShell cmdlet.

A method definition might have one or more method signatures, which are
like the parameter sets of PowerShell cmdlets. The signatures show all of
the valid formats of commands to invoke the method.

For example, the CopyTo method of the FileInfo class contains the following
two method signatures:

        CopyTo(String destFileName)
        CopyTo(String destFileName, Boolean overwrite)

The first method signature takes the destination file name (and a path).
The following example uses the first CopyTo method to copy the Final.txt
file to the C:\Bin directory.

    (Get-ChildItem c:\final.txt).CopyTo("c:\bin\final.txt")

  [!NOTE] Unlike PowerShell's _argument_ mode, object methods execute in
  _expression_ mode, which is a pass-through to the .NET framework that
  PowerShell is built on. In _expression_ mode BAREWORD arguments (unquoted
  strings) are not allowed. You can see this difference when using a the
  path as a parameter, versus the path as an argument. You can read more
  about parsing modes in about_Parsing

The second method signature takes a destination file name and a Boolean
value that determines whether the destination file should be overwritten,
if it already exists.

待续

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值