February 2019
Intermediate to advanced
626 pages
15h 51m
English
A method enacts a change to the object. This may be an internal change, such as opening a connection or stream, or it may take the object and change it into a different form as is the case with the ToString method.
The following class defines a simple ToString method that returns the value of the property:
class MyClass { [String]$Property MyClass() { $this.Property = 'Hello world' } [String] ToString() { return $this.Property }}
When working with methods, and unlike functions in PowerShell, the return keyword is mandatory. Methods do not return output by default. An error will be raised if a method has an output type declared and it does not return output from each code path.
Methods can accept arguments in the same way as constructors. ...
Read now
Unlock full access