Skip to content

Instantly share code, notes, and snippets.

@zett42
Created April 16, 2025 10:32
Show Gist options
  • Select an option

  • Save zett42/fa8aa34e8aed20bdd0a3bd17d516ea95 to your computer and use it in GitHub Desktop.

Select an option

Save zett42/fa8aa34e8aed20bdd0a3bd17d516ea95 to your computer and use it in GitHub Desktop.
Simple PowerShell script to build a C# console application that prints all arguments
# Builds a C# console application that prints all arguments (requires Windows PowerShell 5.1)
Add-Type -OutputType ConsoleApplication -OutputAssembly ShowArgs.exe -TypeDefinition @'
using System;
namespace MyApp
{
class Program
{
static int Main( string[] args )
{
for( int i = 0; i < args.Length; i++ )
{
Console.WriteLine( String.Format( "Arg {0}: {1}", i + 1, args[ i ] ) );
}
return 0;
}
}
}
'@
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment