$source =
@"
public class BasicTest
{
public static int Add(int a, int b) {
return (a + b);
}
public int Multiply(int a, int b) {
return (a * b);
}
}
"@
# type definition - must be declared
Add-Type -TypeDefinition $source
# access a static method
[BasicTest]::Add(4, 3)
# create instance of class and call a non-static method
$basicTestObject = New-Object BasicTest
$basicTestObject.Multiply(5, 2)
@"
public class BasicTest
{
public static int Add(int a, int b) {
return (a + b);
}
public int Multiply(int a, int b) {
return (a * b);
}
}
"@
# type definition - must be declared
Add-Type -TypeDefinition $source
# access a static method
[BasicTest]::Add(4, 3)
# create instance of class and call a non-static method
$basicTestObject = New-Object BasicTest
$basicTestObject.Multiply(5, 2)