Skip to content

Instantly share code, notes, and snippets.

@adamdriscoll
Last active June 10, 2016 15:32
Show Gist options
  • Save adamdriscoll/3e5ac204196a106329a09076965ad31a to your computer and use it in GitHub Desktop.
Save adamdriscoll/3e5ac204196a106329a09076965ad31a to your computer and use it in GitHub Desktop.
Properties are just methods
#Backing methods
[System.Collections.ArrayList].GetMethods() | Where Name -like 'get_*' | Select Name
[System.Collections.ArrayList].GetMethods() | Where Name -like 'set_*' | Select Name
$ArrayList = New-Object System.Collections.ArrayList
$ArrayList.Add(1) | Out-Null
$ArrayList.Add(2) | Out-Null
#Indexer (parameterized property)
$ArrayList[1]
#Underlying method
$ArrayList.get_Item(1)
#Underlying method
$ArrayList.set_Item(1, 10)
#Indexer (parameterized property)
$ArrayList[1]
#Property
$ArrayList.Count
#Underlying method
$ArrayList.get_Count()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment