Sunday, 20 March 2016

C# .Net execute from command line



Open CMD.
c:\users\test\Documents>
Open Notepad. Ex:
c:\users\test\Documents>notepad hello.cs

Write sample code.
Ex:

using System;
class Program
{
static void Main()
{
Console.WriteLine("Hello");
}
}

Save hello.cs
c:\users\test\Documents>

Now in the CMD execute .net exe.

Ex: C:\Windows\Microsoft.NET\Framework\v4.0.30319\csc.exe

now call hello.exe
c:\users\test\Documents> hello.exe

You will get the output Hello