I know that in PowerShell you can insert C# code using Add-Type:
Add-Type
Add-Type -TypeDefinition $code -Language CSharp
The type definition