Created
March 11, 2016 01:21
-
-
Save PlagueHO/47be0d4ad65dd76a06d7 to your computer and use it in GitHub Desktop.
Creating an ICloneable class in PowerShell, with the Clone method implemented.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Car:ICloneable { | |
[Object] Clone () { | |
$NewCar = [Car]::New() | |
foreach ($Property in ($this | Get-Member -MemberType Property)) | |
{ | |
$NewCar.$($Property.Name) = $this.$($Property.Name) | |
} # foreach | |
return $NewCar | |
} # Clone | |
[String] $Make | |
[String] $Model | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment