Quite often, I quickly need to test a small piece of code and if you’re doing some customization on SharePoint, I hate to open project, apply the code, publish, and deploy over the server (retract, remove and redeploy!). I post this, so I can copy and paste and run the code quickly.
static void Main(string args)
// Keep the console window open in debug mode.
Console.WriteLine("Press any key to exit.");
Run command prompt as administrator and change the directory as follows
C:\Windows\Microsoft.NET\Framework64\v4.0.30319>csc -out:"C:\EPM\Code\my code.exe" C:\epm\code\main.cs
Microsoft (R) Visual C# Compiler version 4.6.1586.0
for C# 5
Copyright (C) Microsoft Corporation. All rights reserved.
This compiler is provided as part of the Microsoft (R) .NET Framework, but only supports
language versions up to C# 5, which is no longer the latest version. For compilers that
support newer versions of the C# programming language,
Compile the code as given below. You will have your exe file in the defined path.
Double-click the file and there you go, you’ll get your code running in no time.