Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Run C# code in PowerShell
$assemblies=(
"System"
)
$source=@"
using System;
namespace Helloworld
{
public static class Hello{
public static void Main(){
Console.WriteLine("Hello, world!");
}
}
}
"@
Add-Type -ReferencedAssemblies $assemblies -TypeDefinition $source -Language CSharp
[HelloWorld.Hello]::Main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment